running a process in background in linux [duplicate] - java

This question already has answers here:
How to run Node.js as a background process and never die?
(14 answers)
Closed 5 years ago.
I want to run this in background.
Here is the content of my .sh file.
Please suggest me
java -Dlogback.configurationFile=logback.xml -jar report-schedule.jar $1

You can use & at the end of your shell command,
sh YourScriptShell.sh &
Or you can also use Ctrl+z and then write bg
bg for background.
To retrieve it in foreground, use fg
And that's it :)

use
nohup your_shellscript &

Related

Calling java from shellscript with parameters [duplicate]

This question already has answers here:
Propagate all arguments in a Bash shell script
(12 answers)
Closed 3 years ago.
From a shell script, I would like to call a shell script which calls a java program. The parameters to the java program are passed from the first shell script.
shellscript1 --> shellscript2 (set par1) --> Java par1
I have tried to source shellscript2 in shellscript1. Still couldnt pass parameters. I dont want to export the parameters and call shellscript2
Any ideas appreciated
Do not use shellscript 2 but add the param to shellscript 1. Using 2 shellscripts makes it complex.

how to open program (matlab) using java? [duplicate]

This question already has answers here:
Running MATLAB function from Java
(5 answers)
Closed 7 years ago.
i have project in matlab (neural network) but my GUI is using java (netbeans) and i want to open my matlab project using that GUI. can anyone show me the code to open matlab or other program using java. thanks
You'd want something like this:
Runtime runTime = Runtime.getRuntime();
Process process = runTime.exec("matlab");
process.destroy(); // to kill the app

Open URL with Java, then close the browser [duplicate]

This question already has answers here:
Closing a Web Browser for a specific URL from the java program
(2 answers)
Closed 7 years ago.
I'd like to open an URL in the default browser using Java. So I am doing what the answer in this question says: Open a link in browser with java button?
It works. However, I want to automatically close that browser after some 10 seconds have passed (from Java). This is for Windows machines.
How can I achieve this?
Start the process with:
Process p = Runtime.getRuntime().exec(new String[] {"explorer", "http://google.pl"});
and after your 10 sec call:
p.destroy();

How to execute shell script from Java applet [duplicate]

This question already has answers here:
executing shell scripts in java script or trigger scanner from browser
(2 answers)
Closed 9 years ago.
I want to access a document scanner on client's side so I have created a shell script to perform this action. Is there any way to execute it through a browser applet? Is there a way to make it work on Fedora 18 OS that will allow me to install a plugin like twain? This how I call my script currently:
String[] cmd = {"sh test.sh", "/Path/to my/resource file"};
Runtime.getRuntime().exec(cmd)
You can use Java Web Start or a signed applet.

How to run a java program from another java program? [duplicate]

This question already has answers here:
How to run Java code using Java code?
(4 answers)
Closed 8 years ago.
So I have a java program of a game. I want to have a different program and when you click on a button there that java program closes and starts the program with the game. But I have no idea how I can do that, so can anyone help me?
Using ProcessBuilder.The following is a reference,maybe not work.
ProcessBuilder pb=new ProcessBuilder("java","-jar","Test3.jar");
pb.directory(new File("F:\\dist"));
Map<String,String> map=pb.environment();
Process p=pb.start();
Create a runnable jar.
call the runnable jar on button click.
Exit from the current program.

Categories