Results 1 to 3 of 3
  1. #1
    renu is offline Senior Member
    Join Date
    May 2010
    Posts
    117
    Rep Power
    0

    Question how to execute a jar file

    Hi

    I have written java code using eclipse , this java code has a jdbc connection and classes12.jar has been added to the program and a jar file has been created .

    Now when i try to run the jar file , it does not run . So i created a bat file with the path of the jar file in it and kept the jar file , bat file and classes12.jar file in that folder and tried running the bat file , it is running.

    My question , is does the classes12.jar file should be added to the folder again to execute the bat file ?

    and also how can i achieve running the jar file , without using the bat file ?

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,001
    Rep Power
    20

    Default

    Do you have a Manifest in the jar file?
    Inside that manifest it should say what the main class is, as well as any dependent libraries (ie jar files).

    The classes12.jar isn't in you jar file is it? You can't stick jars in jars like that.

  3. #3
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    when you create a jar from eclipse that contains more classes before you click the finish button in the wizard make sure you have select the class the contains the method main(). after that go to the directory where the jar has been exported and enter

    jar -jar JarName.jar

    and the jar should start.
    Last edited by j2me64; 02-03-2011 at 04:14 PM.

Similar Threads

  1. Replies: 2
    Last Post: 11-23-2010, 05:49 PM
  2. jar file won't execute.
    By Splat in forum New To Java
    Replies: 5
    Last Post: 10-22-2009, 05:26 AM
  3. Execute external file/program
    By sirwiggles in forum New To Java
    Replies: 3
    Last Post: 04-21-2009, 11:35 PM
  4. execute on server and read from file
    By futurpc in forum Networking
    Replies: 1
    Last Post: 03-13-2009, 07:45 PM
  5. Execute Jar file
    By barney in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 07:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •