1、菜单中选择【Wizards】-【Native Executable Builder....】弹出对话框
2、在弹出的对话框中第一步(Step 1 of 7)的【Name】输入一个名称,并取消【Always create archive when building the project】点击【Next】
3、根据需要悬着需要的类,再选择【Include class dependencies】,点击【Next】
4、根据需要悬着需要的库文件,再选择下面的4个单选,反复所有的需要的库,点击【Next】
5、默认点击【Next】
6、在(Step 5 of 7)的时候选择一个主类运行点击【Next】
7、在(Step 6 of 7)的时候选择运行平台【Next】
8、默认点击【Finish】,这时候在工程的目录窗口出现了一个在(Step 1 of 7)输入的【Name】目录
9、右击这个目录,选择【Rebuild....】,Jbuilder就开始编译和创建执行文件或是Jar文件了
10、等完成之后,该目录下右几个文件,一般是有至少一个jar文件,或是一个exe文件
11、在Window打开工程所在的目录,就可以看到里面的有几个刚才编译的文件
12、执行jar就是用java -jar ***.jar、执行exe直接双击

解决方案 »

  1.   

    kaymo:我是按照你的步骤做的,也生成了.exe 文件
    在Dos下用java -jar ***.jar 可以运行程序,但在window里的工程所在的目录下直接双击.exe 文件却还是不行啊?(Dos窗体闪了一下马上就不见了)请高手指教。
      

  2.   

    kaymo:
       
       我用的是JBuilder8,生成了两个.exe文件,一个是untitled.exe,一个是untitledw.exe(图标是一个jBuilder的图标(蓝色圆圈里有一个"J")),我应该用哪一个啊?双击第一个,Dos窗体闪了一下马上就不见了,双击第二个,就弹出消息框:Unable to find a Java Runtime.Please download and install a Java Runtime from http://www.borland.com/jbuilder/resources/javaruntime.html
    我应该怎么办哪?
      

  3.   

    也想知道怎么才能换成.EXE,顶啊!!!!
      

  4.   

    [Java]创建 Java .exe 文件 作者: Builderau.com.au
    Friday, July 9 2004 5:07 PM  需要创建 Java .exe 文件吗?Builder 澳大利亚的 Java 专家 Michael Geisler 在本文中分析了开发人员可以使用的几种方法。问题
    您好,Michael:
    我需要为我的应用程序创建一个 Java .exe文件。创建 Java .exe 文件都需要哪些步骤?有没有什么工具能够帮助我自动地创建 Java .exe 文件?回答
    Sun 提供的标准 Java 开发包(JDK)没有提供创建特定于平台的可执行文件的工具(一点都不吃惊,这是真的)。然而,其实有很多方法能够帮助你实现这一想法。第三方工具 
    一种方法是使用第三方商业工具或免费工具将 Java 应用程序打包为一个可执行文件。下面是价格和特性都不同的两个工具,但是在 Web 上还有其它几个第三方工具可以免费下载。http://www.bysoft.se/sureshot/exej/ 
    http://www.duckware.com/jexepack/ 
    使用商业安装程序(installer)
    InstallAnywhere 是一个常用的安装程序,它将管理应用程序的安装过程,并将应用程序打包为可执行程序。使用 .jar
    除了以上方法之外,还可以将应用程序打包为一个可执行的 .jar 文件,而不是一个 .exe 文件。在这篇文章中我将不详细介绍这种方法,你可以在这里找到一个非常棒的在线教程你需要做的最重要的一件事是指定在 .jar 文件中哪个类是应用程序的入口点。例如,对你的应用程序来说就是具有一个 public static void main(String[] args) 方法的引导类。可以在 .jar 表示文件的 Main-Class 头部信息中提供这些信息。这个头部信息的通用形式为:Main-Class: classname,其中 classname 是应用程序的入口点的类名称。使用 Java Webstart
    Java Webstart 是标准 Java 运行时环境(JRE)的隐藏的宝物,自从版本 1.3 开始,JRE 就包含了 Java Webstart。它是一个简单但功能强大且灵活的将应用程序部署到任何平台的方法。Webstart 允许应用程序的用户从他们的浏览器、电子邮件或桌面启动和管理应用程序。Java Webstart 的一个主要优点是一旦应用程序被安装,在每次启动它时,它都将会检查用户是否在运行最新版本的应用程序。如果不是,应用程序将通过网络装载新版本到桌面然后执行,因此解决了软件传播问题。如果你的应用程序已经有很多用户的话,这一点就尤其重要。还有很重要的一点是,它能够检查用户的本地桌面环境,并能保证他们安装了正确的 JRE 版本来运行你的应用程序。Java Webstart 本身有一系列文章,所以我建议你访问 Java Webstart Web 站点查看更多文档和教程。结束语 
    前两种方法可能会满足你对这个问题的需要,但是我强烈建议你仔细看一下 Java Webstart。它是 Java 标准的一部分,并且能够在所有平台下一致工作。我比较喜欢这个应用程序打包方法。
    --------------------------------------------------------------------------------
    本文作者:Michael Geisler 是 Sun 微系统公司的一位解决方案架构师,他在 IT 和通信行业已经有14年的从业经验。自从第一个 Java 第一个公开 beta 版本发布以来,他就一直使用 Java 编程,目前 Michael Geisler 是澳大利亚 Java 用户组(AJUG)的副总。  
      

  5.   

    Here are eight ways to get what acts like a Java executable file: 1.Use a native compiler. This is the only method that gives you a true machine code executable. You may still have to distribute some DLLs or the JRE along with your executable. 
    2.Set up a shortcut with the appropriate java.exe command to load the class. 
    3.Bundle your classes in a jar with the Main-Class attribute. Set up an association for *.jar to make it executable. 
    4.Write yourself a tiny C program that exec's a Java command to load your class. Assuming the jar file Foo.jar with main class Bar, here how to make a Foo.exe tiny kickoff program. Compile the following program foo.c to foo.exe: 
    #include <process.h> 
    int main(void) 

    execlp("java.exe", 
    "java.exe", 
    "-cp", 
    "foo.jar", 
    "Bar", 
    NULL); 
    return 0; 

    If you want to play really strange games, concatenate the jar file onto the end of your foo.exe kicker, and put the EXE file on the classpath where you would normally need to place foo.jar. This way you can distribute but a single file, albeit uncompressed. Reputedly java.exe will happily treat this combo as a standard jar. Executing the foo.exe just ignores the jar tacked on the end. e.g. change the foo.c code to read 
    #include <process.h> 
    int main(void) 

    execlp("java.exe", 
    "java.exe", 
    "-cp", 
    "foo.exe", 
    "Bar", 
    NULL); 
    return 0; 

    then 
    -------------------------------
    rename foo.exe littlefoo.exe
    copy /b littlefoo.exe + foo.jar foo.exe
    -------------------------------
    You only need distribute foo.exe. 5.Use the InstallAnywhere NOW installer (or other installer). It uses a standard platform-dependent EXE kickoff file for a standard interpreted platform-independent Java application packaged in a jar file. 
    6.Use Microsoft's Jexegen bundler. It only works with the Microsoft JVM. Webgain Café also works this way as does J2Exe. 
    7.Distribute using Java Web Start. Users can click on menu or desktop items to kick off pure java Programs. 
    8.Use exe4J bundle up your jar file and a copy of the JRE into one big installable exe file. Your program runs in the standard Sun Hotspot JIT.