Need help with my .jar
Hello, i just finished writing my project, and i have created a .jar file using my command window. However when i try to run my .jar nothing happens. Im using jdk1.6.0_22.
So do i need to have any specific code to bring up the command window? my program is completely text based, and does not call JFrame.
When i create a jar file i create a manifest file which points to my main class
In this example consider we are in the directory /home/myjars/ and the file is thisjar.jar
If you already have the jar, you should be able to run it by typing this:
java -jar thisjar.jar
If you need help reconstructing your JAR, or possibly making your own manifest file let me know
by the way
Even if it did call a JFrame, you can still run the file from the command line, the frame will pop up just fine, and you can even end it by ctrl c (on unix, dunno about windows)
You can even have a buttons action be to print to the terminal (System.out) as far as i understand it.
ok i typed in the java - jar DesktopApplicationRunner.jar andit ran the program, however i when i double click my .jar file it does nothing
awesome! im glad you got it to run.
One thing, when you 'double click' a file in your graphical desktop, it doesnt nessecissarily attempt to execute it with the java vm. If your on windows or linux with gnome/kde (unsure on xfce) right click the file an d click open with. you may have to enter the path to the java vm manually the first time if your system didnt associate jar files with it. It also could be that double clicking it actually does do something, you just dont see the output
because theres no shell for it to talk to :D If you can run it with java -jar its a good file, and thats good news!
im on windows 7 btw, i looked around and someone said to us a .bat file with -java -jar DesktopApplicationRunner.jar and it does work, but the command window pops up then closes immediately
also i did what you had said about open with and no luck. how do i go about creating a shell?
I use linux so im a bit uneducated on the new windows, however i do use windows 7 at work for tech support. When you said the command line comes up and then just closes, im afraid there may be no way around that, for example if you run the ipconfig command from the run box, it will show the ipconfig display information, but immediately close the shell after. The only way i know of to get it to stay is to actually open a shell (command prompt on windows) and type ipconfig, or in your case run the app via java -jar yourjar,jar
Im sure there has to be some way to make it stay open, looks like we have some researching to do :)
add PAUSE at the end of your bat file, the only way ive found aside from adding /k to the run command
You sure that *.jar registered with Java Platform Standard Edition binary.
lol It worked!!
thanks a lot for the help. lets hope i go to nationals with this program.
Could you please mark the thread solved then?