Run Gradle Java Project in background - java

I have built a Java project using Gradle. It is working fine. I have to run this project on Linux and I want to do it without the terminal window.
If I close the terminal, the project terminates.
How can I run the program without the terminal window?

You can use the nohup command:
nohup <your_command_line> >Output.log 2>&1 &

I found answer to my question . My command is 'gradle runEngineWithMonitoring'.
I can now run this process in background, even after close of terminal in linux by following below steps.
Run
gradle runEngineWithMonitoring &
command.
after this run
disown
command.

Related

Using mvn clean install from cmd, while running the app from intellij its seems like it rebuilding it

I'm trying to automate some mvn commands to set up the dev env in IntelliJ.
I'm running from cmd:
mvn clean install -DskipTests -P profile1,profile2
When it finish, I'm running the app from IntelliJ, it seems like IntelliJ is compelling and building it again before it runs.
Is there a way to add flags to the cmd command in order to save the step of IntelliJ compiling & building it?

Create a script to run multiple java jar in different terminal windows

I wrote an application in java that needs five players and a server.
I need to write a script that executes the jar of the server and of every single player in different terminal windows. How can I do?
I tried a script and worked but the jar opened in the same terminal window than I tried with xterm or konsole with flag --noclose but does not work (warning command: konsole not found)
#! /bin/sh
xterm --hold -e java -jar /Users/Marco\ 1/Documents/ing-sw-2019-Lentini-Marazzi-Marini/out/artifacts/server_jar/adrenalina.jar
for X in $(seq 5)
do
konsole --noclose -e java -jar /Users/Marco\ 1/Documents/ing-sw-2019-Lentini-Marazzi-Marini/out/artifacts/client_jar/adrenalina.jar gui
done
exit;
To run a process in the background from bash, you'll need to add an & to the end of your command, e.g.
java -jar /path/to/jar/my.jar &
Otherwise bash will wait until the command execution terminates.

Android runtime exec stops if caller stops

I'm working with rooted android tablets and I want to execute shell command lines. However, I've seen they stop if the command launcher app stops. If there any way to keep the execution of the shell commands despite the originator app stops?
Thanks
This is exactly what I want to execute. I want to be able to update my app inside my app:
cmd I want to execute inside my App:
am force-stop myapp & install newVersionOfMyApp.apk & monkey -p myapp 1
Then when first part of the command is executed, rest is not executed. I've seen this can be solved in other OS by modifying the command (windows add a "cmd" and linux add "&" at the end). Does Android have any equivalent way?
Finally I found the solution. You can do this by putting it after a nohup command:
nohup sh -c 'am force-stop myapp && install newVersionOfMyApp.apk && monkey -p myapp 1' &
EDITED with information of #syslogic
You'd need to detach the TTY from the console with an & (behind the command); while when the command has exit 0 (success) or exit 1 (error), the execution will halt nevertheless. running cron-jobs wouldn't require any console, at all. What I'm basically trying to tell is, that you probably should reconsider the way of how to put the commands there - while adb shell or cron does not require any GUI.
there also is adb shell monkey - while the MonkeyRunner might have (meanwhile) been replace with the UI Automator from the Support Library.
it's Monkey vs. UI Automator.
I'd write it about like this, in bash - on a PC - with ADB:
adb install -r com.acme.apk && adb shell monkey -p com.acme.AppName -v 500

how to run a jar file on the ubuntu 14.04 without stopping when i stopped the putty?

I am using ubuntu 14.04
I am running a jar file which should be collection a large amount of data for a few days.
I am running the jar file thought this command and it works fine.
java -jar xxx.jar
However when i close the putty, the process stopped. Is there a way for a jar file to run even when i close the putty?
You can use nohup to run the jar(any process) in background.
Use the following command in the putty session :
nohup java -jar xxx.jar &
You need the nohup command. This command makes processes keep running despite closing terminal.
Run your jar with (in case you are in the right folder):
nohup java -jar xxx.jar &
I would suggest to you use
nohup java -jar xxx.jar > /dev/null 2>&1 &
which redirects standard error & output of the command to /dev/null which means it's discarded. If you need the console output of this command then you can redirect it to any file as follows
nohup java -jar xxx.jar > output.log 2>&1 &

Where does the Jenkins Windows installer put java?

I installed the Jenkins MSI sliently
c:\windows\temp\jenkins.msi /qn /L*V c:\windows\temp\jenkins.log
Seems to be running OK, but it appears java is not in the system PATH. Where does the MSI put java?
Edit:
I'm asking this because I want to install plugins like this:
java -jar jenkins-cli.jar -s http://127.0.0.1:8080/ install-plugin http://updates.jenkins-ci.org/download/plugins/aws-lambda/0.5.5/aws-lambda.hpi
I can't run this command because I don't know where to java exe is
It puts it here: 'C:\Program Files (x86)\Jenkins\jre\bin\java.exe'

Categories

Resources