• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jar file execution

 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>"
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Itried running as suggested

 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 12100
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
moving thread at users request.
 
luisrd
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"LuisJava", please check your private messages for an important administrative matter.
 
Paul Clapham
Sheriff
Posts: 20983
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gauravtyagi tyagi,
Your post was moved to a new topic.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic