• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jar file execution

 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Itried running as suggested

 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
moving thread at users request.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"LuisJava", please check your private messages for an important administrative matter.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
gauravtyagi tyagi,
Your post was moved to a new topic.
 
reply
    Bookmark Topic Watch Topic
  • New Topic