Results 1 to 12 of 12
Thread: Need help with my .jar
- 03-11-2011, 09:31 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 9
- Rep Power
- 0
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.
- 03-11-2011, 09:36 PM #2
Member
- Join Date
- Mar 2011
- Posts
- 22
- Rep Power
- 0
few questions
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
- 03-11-2011, 09:40 PM #3
Member
- Join Date
- Mar 2011
- Posts
- 22
- Rep Power
- 0
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.
- 03-11-2011, 09:51 PM #4
Member
- Join Date
- Mar 2011
- Posts
- 9
- Rep Power
- 0
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
- 03-11-2011, 10:45 PM #5
Member
- Join Date
- Mar 2011
- Posts
- 22
- Rep Power
- 0
hey
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!
- 03-11-2011, 10:50 PM #6
Member
- Join Date
- Mar 2011
- Posts
- 9
- Rep Power
- 0
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
- 03-11-2011, 10:59 PM #7
Member
- Join Date
- Mar 2011
- Posts
- 9
- Rep Power
- 0
also i did what you had said about open with and no luck. how do i go about creating a shell?
- 03-12-2011, 12:44 AM #8
Member
- Join Date
- Mar 2011
- Posts
- 22
- Rep Power
- 0
hmm
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 :)
- 03-12-2011, 12:49 AM #9
Member
- Join Date
- Mar 2011
- Posts
- 22
- Rep Power
- 0
add PAUSE at the end of your bat file, the only way ive found aside from adding /k to the run command
- 03-12-2011, 12:51 AM #10
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You sure that *.jar registered with Java Platform Standard Edition binary.
- 03-12-2011, 01:20 AM #11
Member
- Join Date
- Mar 2011
- Posts
- 9
- Rep Power
- 0
lol It worked!!
thanks a lot for the help. lets hope i go to nationals with this program.
- 03-12-2011, 07:44 AM #12
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Could you please mark the thread solved then?


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks