| Author |
jar file execution
|
Gopu Akraju
Ranch Hand
Joined: Jan 13, 2008
Posts: 242
|
|
I have developed a swing application and executing under linux environment. jar file is present under /deo/temp/testing.jar. I have two issues to share now. 1. If I execute my jar file under /deo/temp> java -jar testing.jar, I am able to see my application start running. But if I try like /deo>java -jar /temp/testing.jar, I get the error message "Main method not found" How do I resolve this problem? 2. How do I create an icon so that when the user clicks the jar file, it starts executing. In windows, as I have developed using netbeans, if I double click the ajr file found under dist folder, the program starts executing. As the users are not aware of using command line prompt, I am supposed to make an icon on double clicking should start the program. It would be very useful if I hear some expert advice on both the issues I have mentioned above. Thanks.
|
 |
Mark Freeman
Ranch Hand
Joined: Aug 02, 2006
Posts: 40
|
|
Hey there. 1. The leading / tells the system to start with root. If you want to start from the current directory, add a ".". 2. You could create a .bat file with the cmd line commands in there. I think most systems will automatically run a jar file if the jre is install and added to the system's PATH setting.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Originally posted by Gopu Akraju: I have developed a swing application and executing under linux environment. jar file is present under /deo/temp/testing.jar. I have two issues to share now. 1. If I execute my jar file under /deo/temp> java -jar testing.jar, I am able to see my application start running. But if I try like /deo>java -jar /temp/testing.jar, I get the error message "Main method not found" How do I resolve this problem?
Should that second not be ? Without the / before temp? Because now you are trying to access file /temp/testing.jar, not /deo/temp/testing.jar
2. How do I create an icon so that when the user clicks the jar file, it starts executing. In windows, as I have developed using netbeans, if I double click the ajr file found under dist folder, the program starts executing. As the users are not aware of using command line prompt, I am supposed to make an icon on double clicking should start the program.
It would depend on the Window and Desktop manager you're using. In Windows it works because when you install the JRE, it automatically creates a file association for JAR files to be opened with javaw.exe. In GNOME or KDE you'll probably have to create such a file association yourself; please check the GNOME / KDE documentation on how to. Alternatively, you can create a shortcut for the users that executes "javaw <your JAR file>"
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Gopu Akraju
Ranch Hand
Joined: Jan 13, 2008
Posts: 242
|
|
Itried running as suggested
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
|
|
|
now you need to go through the usual procedure for debugging a NullPointerException. Please search the forum for NullPointerException; it comes up frequently
|
 |
Gopu Akraju
Ranch Hand
Joined: Jan 13, 2008
Posts: 242
|
|
Can this be solved by setting the path for my instance of jar file? No idea about linux environment. Thanks. [ May 08, 2008: Message edited by: Gopu Akraju ]
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9940
|
|
|
moving thread at users request.
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
luisrd
Greenhorn
Joined: Dec 06, 2008
Posts: 1
|
|
For those who have trouble with Vista and double clicking on Jar files. Where JAR files say Main not found. The resolution is to clear the file association with "ASSOC .JAR=" and then set it back to "ASSOC .JAR=jarfile" Close your windows and go back to the folder. You should be able to double click now.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56164
|
|
|
"LuisJava", please check your private messages for an important administrative matter.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16482
|
|
gauravtyagi tyagi, Your post was moved to a new topic.
|
 |
 |
|
|
subject: jar file execution
|
|
|