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?).
@};-
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)
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
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. :D
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?
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 :)
Re: Executable .jar file isn’t launched after being double-clicked
Quote:
Originally Posted by
helloworld922
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:
Quote:
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
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)