I use Windows 8.1, I start program instance by command line. There is this line
java -jar "C:\Program Files (x86)\Jenkins\jenkins.war" --ajp13Port=-1 --httpPort=8082
Program starts and everything is all right. But i want to hide console from task menu. Is it possible to run program by command line in this way?
You could use
1) javaw - java without console window to start your application
or
2) start /b *command* - to start a background task
Why not using javaw instead of java?
Related
Let's say I have a java program and I write this to the command line:
java javafile.jar
Is there anyway to start the java file minimized (somthing similar to /min command)? I need to do it through the commands line.
try start /min java javafile.jar
I have created a batch file which calls a java process in background. All I want is to redirect the logs of the java process to a 'NUL' output so that the background terminal does not contain any output.
Contents of my batch file:
#echo off
START /MIN java -jar ./myapp.jar >null 2>&1
However when I run the batch, I minimized windows terminal opens up which still displays all the logs.
I require to disable this logging, without changing the app.jar
If you just want to ignore any console input and output, execute your Java program on a Windows platform and need to prevent the opening of a console window, then use the javaw executable instead of java.
dotvav's solution is best in your scenario, but for the record the proximate problem with your batch script as posted is that the redirection applies to the START command, not to the java command.
A corrected version would look something like this:
START /MIN cmd /c "java -jar ./myapp.jar >NUL 2>&1"
im trying to do something simple, i want to start Burp Suite with extra java memory, but i don't want the CMD window to stay open.
If i don't use a .bat file and simple open cmd and type start /b "" java -jar -Xmx2g burpsuite_pro_v1.6.07.jar, Burp opens, the the process is sent to background, but the CMD window stays open. i can, however, close it manually and Burp will keep working.
when i try to put the thing into a CMD window, it will not even be sent to background, Burp stays dependent on the CMD, and i cant even add exit to the file.
i tried to solve the issue by following:
run bat file in background - this worked, but required me to have THREE files, i prefer a more elegant "1 file solution"
Just add the below line in your bat file and the java procees will run in background with no window open!
start javaw {Path of Your jar or Java file}
The following batch file commands should accomplish your purpose:
start "" /B java.exe -Xmx2g -jar burpsuite_pro_v1.6.07.jar
exit
You can probably even leave out the /B switch.
References
How can I run a program from a batch file without leaving the console open after the program start?
How to use the start command in a batch file?
Turns out the solution was simple: using javaw.
the issue was with using java.exe, some attempts even closed the CMD but opened a java.exe window (blank)
modding the file to contain:
start javaw -Xmx2g -jar burpsuite_pro_v1.6.07.jar solved it for me.
I have a Java application that runs great :) While uploading files, it uses the standard output to show progress : "System.out.println(...);".
When I run it in Eclipse, well it works perfectly, but when I run the JAR file, I don't see any console/terminal showing up and printing what I print through "System.out.println(...),".
How can I open a new terminal when my application is launched (it is a Swing application)?
Basically I want to be able to run the Swing application and show information on the side in a terminal / console. Why? Don't worry about why I want to do this ;)
Thanks a lot!
Regards.
Open terminal and run application as java -cp yourjar.jar YouMain or java -jar yourjar.jar if you jar is runnable.
I believe that you do not see output because you are running your application using javaw - the special windows-only variation of JVM that does not have STDOUT at all. If you want to click your application and see output map *.jar file to be opened using java instead of javaw. Alternatively write bat file that runs your application. In this case you will see console.
Use java instead of javaw to launch your application. Double-clicking on a jar executes it with javaw. Instead, open a command line window and type
java -jar thePathOfTheJarFile.jar
If you want to have something double-clickable, then write a shell script containing this command, and double-click the shell script instead of the jar.
I am working on a Java application which will be used to launch other applications. Now, most of those have a GUI, but some are command-line tools. For the latter, I would like to open the appropriate command line and have them execute there.
That is, on Windows, I would like to open cmd.exe, and run the tool with the appropriate arguments. The problem is getting cmd.exe to stay open.
When I use ProcessBuilder to start
cmd.exe /k java -version
I get the desired output (I capture the output streams), but the cmd.exe window isn't visible.
When I run
cmd.exe /k start java -version
the cmd.exe window pops up for a split second and then disappears.
But when I just run cmd.exe /k start the cmd.exe window appears and stays open, while cmd.exe start doesn't show a window (as I would expect).
What I want is for the command line tool to run in its own cmd.exe and stay open for input.
Running this from the cmd.exe works.
cmd start cmd /k java -version
However, this just waits for you to run more cmd's.
If you want it to wait for user input use
cmd start java MyProgramWhichWaitsForInput
This was solved using the answer in "Starting a Java tool with cmd.exe". I suspected the problems were separate, but they were not.