We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(8)
基本思想(为您提供一些要搜索的内容)是:将
当您运行“干净构建”时,您可能会发现您的 IDE 已经创建了它。 Netbeans 将其放入“dist”文件夹中。
现代 JRE 允许您通过双击 jar 等方式来运行该 jar。
您还可以更进一步,使用 JSmooth 等工具将 jar 包装在本机可执行文件中。
The basic idea (to give you some things to search for) is:
You might find your IDE already creates this when you run a 'clean build'. Netbeans puts this into a 'dist' folder.
Modern JREs will allow you to run the jar by double clicking it etc.
You can also go a bit further by wrapping the jar in a native executable using a tool such as JSmooth.
查看可执行 jar。 这是精确的,没有任何细节, 创建可执行 jar 文件。
Look at executable jar. Here is the precise one, without any details, Creating executable jar files.
你使用什么IDE?
根据 IDE,某些支持 导出功能将为您创建 .jar 可执行文件。 例如,在 Eclipse 中,您就有该选项。 另外,还有其他适用于 Eclipse 的插件,例如 Fat-Jar,其中将包含您需要的任何其他库包括不属于 Sun 标准库的一部分。
What IDE are you using?
Depending on the IDE, some support Export features that will create the .jar executable for you. For example, in Eclipse, you've got that option. Plus there are additional plug-ins for Eclipse, such as Fat-Jar, that will include any additional libs you include that aren't part of Sun's standard libs.
Java 文件必须通过 Java 虚拟机运行,因此您可以从命令行运行类文件。
如果您有一个名为 filename.java 的文件,请将其编译为 filename.class,然后您可以通过键入 java filename 从命令行运行它>
Java files have to run through the Java Virtual Machine, so you can run your class files from the command line.
If you have a file called filename.java you compile it to filename.class and then you can run it from a command line by typing java filename
如果您想在 Windows 上分发应用程序,请查看 JSmooth。
If you want to distribute your application on Windows, look into JSmooth.
JNLP/网络启动
JNLP/Web Start
此外,为了实现此目的,您可以选择:
或者,如果您要做严肃的事情,请选择像 Ant 或 Maven 这样的构建脚本。
以下是 Ant build.xml 脚本的示例:
Plus to achieve this you can either choose:
Or if you going to to serious stuff, opt for a build script like Ant or Maven.
Here's an example of an Ant build.xml script:
只需退出 IDE 并熟悉命令行工具即可。 java 教程 有关于该主题的线索 此处(选择 Windows 或 Solaris/Linux 部分)。
Just get out of the IDE and familiarise yourself with the command line tools. The java tutorial has a trail on the subject here (pick the Windows or Solaris/Linux section).