Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Executable .jar file isn’t launched after being double-clicked

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Executable .jar file isn’t launched after being double-clicked

    I use NetBeans IDE 4.1. I wrote 5 classes one of them is the main class. All the code is free of errors, I tested it very well, and it does work as it should (as expected)

    I am new in producing executable files, I discovered later that netBenas produces jar files automatically found in dist folder. OK now I have (jar) file for my project (the one described above), but when I double-click on the icon, simply nothing happens.

    I have many other projects that are launched after double-clicking their jar file, but I noticed that those projects usually contain only two related classes the main one and the one that has the working code. (does it matter?).





  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Executable .jar file isn’t launched after being double-clicked

    It is likely that these classes only have console output. In these cases, nothing will be displayed since the Java console window isn't opened. You also need to make sure that the related classes are locatable by your jar file. I'm not sure how netbeans packs the jar files, but I know in Eclipse you can pack all necessary dependencies into the same jar file (for small projects), or can setup the jar file to look for eternal dependencies. As far as I know, there's not really a limit to the number of classes you can pack into a jar file.

    I think there's also a setting somewhere with the jar files that sets them to be executable, otherwise they will function more or less like compressed files (similar to .zip/other formats)

  3. #3
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Executable .jar file isn’t launched after being double-clicked

    Could you show us the content of the manifest file inside the jar?

    // Json

  4. #4
    Junior Member
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Executable .jar file isn’t launched after being double-clicked

    Hi helloworld922, Hi Json Thank you for your responds

    my problem has been solved.

    After I read helloworld922's reply above, I discovered a new term to me which is "console output". Hence I started googling (Google) it to get some information about what does it mean. Well, the full image and concept is not complete to me. But I got general idea about "console output".

    So long as its complex (for me, as I think) I decided to leave solving my problem aside because I think it doesn’t worth so much. I did some changes to my code to improve some aspects of it (there are no errors – just improvements). After that, surprisingly (for me) the executable jar file became launchable without any intention to do anything for it. I just double-click it and work.

    Now I have a little question:

    If I want to use my simple program in other computer, does this (jar) file the one I should move to that computer?

  5. #5
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Executable .jar file isn’t launched after being double-clicked

    As long as everything needed to run that program is in the jar file (such as pictures/sound files/etc.), then you should be fine. Of course, the other machine will also need Java installed on it, too

  6. #6
    Junior Member
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Executable .jar file isn’t launched after being double-clicked

    Quote Originally Posted by helloworld922 View Post
    As long as everything needed to run that program is in the jar file (such as pictures/sound files/etc.), then you should be fine. Of course, the other machine will also need Java installed on it, too
    Thank you helloworld922

    I have a little question:


    Could you show us the content of the manifest file inside the jar?
    How can I open the jar file to get the manifest file?

    Actually there is a file called "manifest.mf" exists in the main project folder, and the “jar” file exists in a folder called "dist" which exists in the main project folder

  7. #7

    Default Re: Executable .jar file isn’t launched after being double-clicked

    If you use something like WinRAR, you can go inside a .JAR as if it was a ZIP because a .JAR file is an archive (compressed folder)

Similar Threads

  1. Java program to format a double value to 2 decimal places
    By JavaPF in forum Java Programming Tutorials
    Replies: 3
    Last Post: December 4th, 2010, 04:08 PM
  2. Formatting output of a Double
    By CarlMartin10 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 11th, 2010, 04:20 PM
  3. Making executable JAR more "executable"
    By ni4ni in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 1st, 2010, 01:19 PM
  4. Double Buffering
    By Ganezan in forum Java Theory & Questions
    Replies: 2
    Last Post: November 20th, 2009, 03:51 AM
  5. string to double
    By wolfgar in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 13th, 2009, 10:47 PM