Reputation: 4283
EDIT
The jar file now runs from the desktop after clean and build and copying it there BUT to make it happen I had to delete the external library containing Utilities.jar
and include the source as another java class.
This isn't acceptable but maybe it tells what to do to make the problem below go away.
When compiling with external library containing Utilities.jar
, I find a lib
folder inside the dist
folder, and inside it is Utilities.jar
.
The Readme.txt
file in the dist
folder says:
======================== BUILD OUTPUT DESCRIPTION =====
When you build an Java application project that has a main class, the IDE
automatically copies all of the JAR files on the projects classpath to your
projects dist/lib folder. The IDE also adds each of the JAR files to the
Class-Path element in the application JAR files manifest file (MANIFEST.MF).
To run the project from the command line, go to the dist folder and
type the following:
java -jar "MrCopy.jar"
To distribute this project, zip up the dist folder (including the
lib folder) and distribute the ZIP file.
Notes:
* If a library on the projects classpath also has a Class-Path element
specified in the manifest, the content
of the Class-Path element has to be on the projects runtime path.
Here's what's in manifest.mf
:
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Should I add anything to it?
If I follow the advice in the readme
and "zip up the .jar and lib
folder" and put the .zip
folder on the desktop and unzip it and run the .jar file, the program runs normally, as it should.
And if I run from command line from the dist
folder via javac -jar mrcopy.jar
, it of course runs right.
But I've never had to go through all this just to get an executable .jar file.
I'm so confused.................
Is it just this simple: If I have external libraries, I'm going to have to zip them up, distribute the zip, unzip the zip and run the .jar file from wherever it got unzipped to?
End of edit
For years, after modifying and compiling MrCopy.jar
, I could copy the .jar file (that is found in the ...\NetBeansProjects\MrCopy\dist
folder) to my desktop and run it. Here's what SHOULD happen:
That dialog pops up and clicking YES leads to copying and the screen below at end:
But now that I'm compiling (as of today) using JAVA 8
in Project Properties Source\Binary format
, I don't get the first dialog and nothing happens.
Here's what Project Properties Packaging looks like:
What can I do to make .jar file run from desktop?
Upvotes: 0
Views: 1379