I need to open run two jar applications in the same time
I know that to run a jar file you have to type
java -jar app1.jar
but I need to terminate the current process to run
java -jar app2.jar
How can I open app2 without closing app1 ?
Execute this bash command
( java -jar app1.jar ) &
( java -jar app2.jar )
The commands will execute in parallel subshells
You can run one, push it into the background, and then run the other.
Run the first command, press ctrl-z and then type bg.
This runs the command in the background, leaving your command line available for you to call you next command.
http://www.thegeekstuff.com/2010/05/unix-background-job/
Related
Trying to setup a desktop entry on ubuntu 21.04 for a .jar file. When I execute it manually with:
$ java -jar /home/usr/Documents/launcher.jar
It outputs some logs from the jar and seems to throw that process into the background.
So as long as the terminal is open it stays running.
But when I setup the .desktop file:
[Desktop Entry]
Type=Application
Terminal=true
Icon=/home/usr/Pictures/logos/launcher.png
Exec=java -jar "/home/usr/Documents/launcher.jar"
Name=Launcher
Comment=Launcher information here
And when I run it a terminal opens showing the logs as expected but then it just closes immediately after and the launcher never actually starts. I was able to take a screenshot of the terminal before it closed/exited and there was no errors or unexpected logging.
UPDATE 1:
I tried to see if running it manually with following command gave the same output and running it as a desktop app and it did. Failed to actually launch launcher.jar
$ gnome-terminal -e "java -jar /home/usr/Documents/launcher.jar"
Have you try to use nohup command?
Add it before your java command and redirect outputs:
nohup java -jar [...] > launcher.log 2>&1 &
I have a UrbanCode Deploy process with a Command Line step that will run an executable jar myjar.jar
In Windows command line, to run as a separate process (so that the command line won't be blocked after I run the jar)
start java -jar myjar.jar
However if I run this command in a uDeploy step, the deploy process will just keep running (I assume it doesn't spawn a separate process).
How to achieve this via uDeploy? Thank you
Try using Deamon option https://developer.ibm.com/urbancode/plugindoc/ibmucd/shell/1-2/steps/, this will run in the background and will not hold your current step for long
I can run one program in my shell (Linux), but executing the same command on the same PC with PHP (using system or exec commands) does not work.
I can execute simple commands using system command in PHP (like ls or which Java).
I changed the permission of particular folder/program, and used whole path for my files and program.
system("/usr/bin/java -jar /pathforprogram/programe.jar -convert /pathtforinput/inputfile.txt -xtg outputfile.txt >optional.txt");
What can be the reason for this?
It is possible to execute external commands in java at run time.
However, what I am looking for is to actually open cmd or terminal and show that executing external command on screen.
I tried to execute a jar console application as java -jar jartool arguments, it works both on Windows and Ubuntu. The only problem is that, this does not open cmd or terminal separately. it runs the command in background.
We can use either ProcessBuilder and the start process or simply Runtime.getRuntime().exec.
I need to forcefully open the cmd or terminal. Java is configured to show console on windows but still no luck.
Any idea why this is happening or what should I do to force it to open cmd or terminal independent of current cmd or terminal.
I'm trying to run a batch file that included multiple jar files, Batch file includes 3 Jar files which executes one after another in one window, My batch file is working correctly for one record which fetches data from excel sheet.
Consider a scenario in which i have 5 records and i wanted to run the batch file in the manner like for 1st record->1st jar prog executes then 1st record->2nd jar file and finally 1st record->3rd jar file executes. Then this loop continues for the second record and likewise. Could anyone please help me to modify the below script which runs in loop and i want to save a executed results in a separate text file.
My script is below:
REM Run first and finish ...
java -jar first.jar
REM .. then start number two.
java -jar second.jar
REM .. then start number three.
java -jar third.jar
Kindly help!
You cloud do something like this that waits until the execution of one jarfile is done.
#echo off
java -jar 1.jar
pause
java -jar 2.jar
pause
If you want to run the jars sequentially, you can write a .bat file containing the following;
#echo off
java -jar first.jar
java -jar second.jar
java -jar third.jar
If you want to tun the jars simultaneously, you can write the .bat file as follows;
#echo off
start java -jar first.jar
start java -jar second.jar
start java -jar third.jar
START command will start running the jar in a new window.
You'll need something like
FOR %%A in (1 2 3 4 5) DO (
java -jar first.jar
java -jar second.jar
java -jar third.jar
)
That should execute the three jar consecutively five times. I didn't actually test this, but it should give you the idea. Here is an article on FOR loops syntax in batch files: http://www.robvanderwoude.com/for.php