Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Packing Java class files into a JAR

  • 12-03-2007 4:19pm
    #1
    Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭


    Hi all,

    I'm trying to pack a number of Java files into a Jar file, which i can execute by just clicking on it...

    I can build a Jar file, but i have to execute it from the command prompt using:-
    java -jar example.jar

    If i just click on the Jar file in explorer, i just get a "main class not found error"

    I've tried all the different options, including using a manafest file (also the trick about leaving a blank line at the end of it ) ect...

    Anyone any ideas??


Comments

  • Registered Users, Registered Users 2 Posts: 6,334 ✭✭✭OfflerCrocGod


    inside a META-INF folder I have a file called MANIFEST.MF with

    Manifest-Version: 1.0
    Created-By: 1.5.0_03 (Sun Microsystems Inc.)
    Main-Class: SongSync

    inside it and no empty line at the top. Works for me, might be something in your command line options for jar.


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Offler pretty much has the jist of it.

    Google is your friend. :)
    http://csdl.ics.hawaii.edu/~johnson/613f99/modules/04/jar-files.html


  • Registered Users, Registered Users 2 Posts: 6,334 ✭✭✭OfflerCrocGod


    This website here explains it all.


  • Registered Users, Registered Users 2 Posts: 6,334 ✭✭✭OfflerCrocGod


    Hobbes spying on my browsing :D btw DublinDilbert I just jarred an unrelated project by following exactly those instructions and it worked just fine.


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    Hi Guys,

    thanks for the replies....

    I inflated the Jar file and i have the manafest file in the correct location, and it looks ok:-
    Manifest-Version: 1.0
    Created-By: 1.6.0 (Sun Microsystems Inc.)
    Main-Class: BookServer

    I can run the Jar from the comand line no problem... but when i double click on the Jar file it says it can't find "main".

    Basically I'm trying to pack the Jar file so someone just needs to click on it to run it...

    thanks again,
    DD


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    Hi All,

    Had another quick look, it looks like an older version of the JVM is being called when I try open the JAR file by double clicking on it..

    I have version 1.6 installed, and when i run from the command prompt this is what runs... but when i double click on it 1.5 is running...

    I wonder is that it... .

    Dave


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    What version is required to run? You may have to specify that in the manifest as well.


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    Well at the comand prompt I've set my path so i get Java 1.6.... but when i double click on the JAR file it wants to launch with 1.5 which i had installed before, I'd say just windows has associated the JAR files with the earlier JVM... It's the only think i can think of, as to why it can run the JAR file from the command prompt and not from windows...

    If anyone knows of any applications that can make the JAR file look like an EXE that would be great also.. I've tried one and i get the same error as when i click on the JAR file "can't find main"....

    thanks again...


Advertisement