Java 8 .jar文件不能使用Netbeans 8.0.2从桌面运行来编译WITH EXTERNAL LIBRARY;如果库包含在源中,则运行正常 [英] Java 8 .jar file won't run from desktop using Netbeans 8.0.2 to compile WITH EXTERNAL LIBRARY; runs fine if library is included in source
问题描述
编辑
EDIT
清洁后, jar文件现在从桌面运行并在那里构建并复制 但是 以实现它我必须删除包含 Utilities.jar的外部库
并将源包含为另一个java类。
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.
使用包含 Utilities.jar
的外部库进行编译时,我发现 lib
dist
文件夹中的文件夹,里面是 Utilities.jar
。
When compiling with external library containing Utilities.jar
, I find a lib
folder inside the dist
folder, and inside it is Utilities.jar
.
dist
Readme.txt 文件>文件夹说:
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.
这是 manifest.mf
中的内容:
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
我应该添加任何内容吗?
Should I add anything to it?
如果我按照自述
中的建议和压缩.jar和 lib
文件夹并输入 .zip
桌面上的文件夹并解压缩并运行.jar文件,程序正常运行,应该如此。
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.
如果我从命令行从 dist
文件夹通过 javac -jar mrcopy.jar
运行,当然它运行正确。
And if I run from command line from the dist
folder via javac -jar mrcopy.jar
, it of course runs right.
但我从来没有经历过这一切只是为了得到一个可执行的.jar文件。
But I've never had to go through all this just to get an executable .jar file.
我'我很困惑.................
I'm so confused.................
这只是这么简单:
如果我有外部库,我将不得不压缩它们,分发zip,解压缩zip并从任何地方运行.jar文件解压缩到?
编辑结束
多年在修改和编译 MrCopy.jar
之后,我可以复制.jar文件(可以在 ... \ NetBeansProjects\MrCopy中找到) \\\
文件夹)到我的桌面并运行它。以下是应该发生的事情:
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:
但现在我正在使用项目属性中的 JAVA 8
编译(截至今天) Source \ Binary格式
,我没有得到第一个对话框,没有任何反应。
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.
以下是Project Properties Packaging的样子:
Here's what Project Properties Packaging looks like:
我该怎么做才能使.jar文件从deskto运行p?
What can I do to make .jar file run from desktop?
推荐答案
如果我理解正确,你有一个项目与其他库的依赖?
If i'm understanding right, you have a project with dependencies from other libs?
如果是这样,你可以做两件事来分发你的应用程序:
If so, you could do two things to distribute your app:
1 - 创建一个胖罐你可以看到它此处
1 - create a fat Jar you can see it here
2 - 压缩项目/ dist文件夹的内容就像你说的那样
2 - zip the content of the project/dist folder just like you said
这篇关于Java 8 .jar文件不能使用Netbeans 8.0.2从桌面运行来编译WITH EXTERNAL LIBRARY;如果库包含在源中,则运行正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!