I would like to see some of the System.out and accept some inputs from it for testing my application on other computers which do not have Eclipse on them.
Normally, if you run the jar by double-clicking then the console output won't be shown.
However, you can launch the command line application (Terminal/CMD depending on your OS) then use the cd command to navigate to the directory of the jar file. Then type:
java -jar [app_name.jar]
This will run the application and show output within the console.
Related
I have made JAR file using Netbeans IDE's clean & build option. When I'm double clicking that Jar file, programs runs with javaw which is not showing me output in console i.e in command window
I want to make Jar file with Java.exe instead of jawaw using netbeans, which will run on double click or with windows task scheduler and display me output in command prompt. Please help me for this issue.
On double click it will run with javaw by default. Better way to do so is make the Jar file and then convert it to .exe file with Launch4J with below settings,
In Basic tab - Specify Output.exe filename.
In Basic tab - Set the jar file location.
In JRE tab specify the minimum JRE version.
In Header tab - Change Header type to console instead of GUI.
And build the wrapper.
4th step will sort your problem, Which will run program in console(command prompt) on running .exe file either on double click or running from Windows Task scheduler.
The jar file built has nothing to do with java or javaw when you double click it. Your machine is set to use javaw when running a jar.
To use java just run it from a command line:
java -jar myjar.jar
To run it via command line, you could always make a batch script to launch the jar.
I implemented an application that can 'works' in GUI mode or in console mode. That means if the user ( in a windows console cmd) launchs the application without parameter\>myapplication.jar
the GUI start. If the user starts the application and gives some parameters, like\>myapplication.jar -src sourcefile, the gui isn't started but the prg interprets the arguments. Now my problem, if a run the application with the prefix \>java -jar myapplication.jar -somethings I see all system.out.println() in the console, it's fine. If I start the application \>myapplication.jar -somethings , all my system.out.println(..) aren't displayed ?? in the console. Why ?
Somebody has a solution to avoid to type each time the prefix >java -jar. I don't want to use a script like 'bash file' before. Thanks in advance, Alex
(some precisions, the system is windows 7 and I don't have the admin right on this pc)
java -jar ... tells the commandline to run java with the specified arguments in the open console. somejar.jar -arg tells windows to open somejar.jar with the given argument. but this will create a completely new process that does not use the console in which you typed the command. So 'somejar.jar' is printing, but not to a visible console.
I have been developing a Java app with Eclipse on Mac OS X. Up to this point, I have been running the app through Eclipse and printing to the Eclipse console with System.out.println().
After I bundle my jar into a Mac app and run it by itself, console output no longer works for obvious reasons. Is there any way to print to the Eclipse console from my externally running jar? Thanks for any help.
Run it from the command line.
run it from another Java program as a separate JVM process, and capture the InputStream, OutputStream, and ErrorStreams for input and output.
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 have a Java standalone project in Eclipse with about 10 packages. I have a main method(in eclipse) that when executed from Eclipse works fine.
I have written a batch file to run it from the desktop. I just click the batch file and hope to run the program.
My code for the batch file is as follows.
RunExecuteMyProg.bat
echo Output of the Program
echo ---------------------
java C:\eclipse_workspace\eclipse\myprogram\MainProgram\ExecuteMainProgram
echo "Program Executed"
This program when run in Eclipse, usually takes between 1 -4 min depending on a number of factors. But when I click the .bat file, it opens for a fraction of a second and closes. Java is on my classpath. At command prompt when I try to compile, I get compile errors saying that some class is not found. However on eclipse it just runs fine. Log files need to get created when this program runs, but nothing happens from batch file.
PS: The class files are created in the same folder as the source files.
You will know the problem if you open a command prompt and enter that command you have there:
java C:\eclipse_workspace\eclipse\myprogram\MainProgram\ExecuteMainProgram
It could be that you don't have java in the path or your program is written so that it has to have its current working directory where the program is located, etc etc.
Or any number of things. Get the output from executing that command manually in a command prompt.