我在此引述一篇文章,希望能有所帮助。How can I run my Java program as a native executable? - by Borland Developer Support StaffAbstract:A neat trick in JBuilder (3.5 and later) that allows you to run your app as an exe.Question: How can I use JBuilder to make my Java program into an native executable?
Answer: JBuilder does not feature a native compiler but there is a neat feature in JBuilder that will allow you to run you Java programs from an executable, with or without a console. To do this, you will need the following files from your JBuilder "bin" directory (assuming Windows, use comparable files if on Solaris or Linux): JBuilder.exe JBuilderW.exe JBuilder.config jdk.config JavaLauncher.dll "JBuilder.exe" is basically a general purpose executable wrapper for launching Java programs, and "JBuilderW.exe" just wraps "JBuilder.exe". The key to using them is in the file names. "JBuilder.exe" looks for a file called "JBuilder.config" to find the configuration information necessary to launch the Java program. Similarly, "JBuilderW.exe" looks for "JBuilder.exe" and launches it without a console. If you rename the file to "foo.exe" then it will look for "foo.config" for configuration information. The same holds for "JBuilderW.exe". Rename it to "fooW.exe" and you will be able to luanch you java application without a console window, assuming that you have everything setup in "foo.config". For hints on setting on the ".config" file, see the "JBuilder.config" file as well as the "Readme.txt" file in your JBuilder 3.5 "bin" directory. This little feature is enough to give you a way to launch your Java application from an exe, but now for the fun part. Let's say you have your Java program deployed to "myApp.jar". You've created a "foo.config" that specifies the location of the JDK so that the launcher can launch your program and you've renamed the launcher to "foo.exe". Here's what to do next: Combine "foo.exe" and "myApp.jar" into one file. To do this in DOS you use a command like: COPY /B foo.exe+myApp.jar foo.exeAdd "foo.exe" to the classpath in the "foo.config" file with the "addpath" directive: addpath C:/stuff/foo.exeTo recap, you should now have these files in the same directory: "foo.exe"; "foo.config"; and "JavaLauncher.dll". You should now be able to use "foo.exe" to launch your Java program. Additionally, if you have "fooW.exe" then you will be able to launch your program wihout a console. Why does it work? Simply put, the structure of executables and jar/zip archives makes this possible. An executable has all of the "important stuff" at the front of the file, so you can attach any amount of junk (or a jar file) onto the end of it. A jar (or zip) file on the other hand, has all of the "important stuff" at the end of the file. So, by combining the two, the executable portion can execute without problems and the executable can also be used as an archive on the class path (assuming that Sun doesn't start checking for "correct" file extensions). Enjoy!
或用jet把class文件做成exe文件。
记住只有3.0有,3.5都没有,呵呵,因为SUN公司觉得,做成Exe文件,与java的初衷相违背了!
不给borland 公司这样做!
How can I use JBuilder to make my Java program into an native executable?
Answer:
JBuilder does not feature a native compiler but there is a neat feature in JBuilder that will allow you to run you Java programs from an executable, with or without a console. To do this, you will need the following files from your JBuilder "bin" directory (assuming Windows, use comparable files if on Solaris or Linux): JBuilder.exe
JBuilderW.exe
JBuilder.config
jdk.config
JavaLauncher.dll
"JBuilder.exe" is basically a general purpose executable wrapper for launching Java programs, and "JBuilderW.exe" just wraps "JBuilder.exe". The key to using them is in the file names. "JBuilder.exe" looks for a file called "JBuilder.config" to find the configuration information necessary to launch the Java program. Similarly, "JBuilderW.exe" looks for "JBuilder.exe" and launches it without a console. If you rename the file to "foo.exe" then it will look for "foo.config" for configuration information. The same holds for "JBuilderW.exe". Rename it to "fooW.exe" and you will be able to luanch you java application without a console window, assuming that you have everything setup in "foo.config". For hints on setting on the ".config" file, see the "JBuilder.config" file as well as the "Readme.txt" file in your JBuilder 3.5 "bin" directory. This little feature is enough to give you a way to launch your Java application from an exe, but now for the fun part. Let's say you have your Java program deployed to "myApp.jar". You've created a "foo.config" that specifies the location of the JDK so that the launcher can launch your program and you've renamed the launcher to "foo.exe". Here's what to do next: Combine "foo.exe" and "myApp.jar" into one file. To do this in DOS you use a command like:
COPY /B foo.exe+myApp.jar foo.exeAdd "foo.exe" to the classpath in the "foo.config" file with the "addpath" directive:
addpath C:/stuff/foo.exeTo recap, you should now have these files in the same directory: "foo.exe"; "foo.config"; and "JavaLauncher.dll". You should now be able to use "foo.exe" to launch your Java program. Additionally, if you have "fooW.exe" then you will be able to launch your program wihout a console. Why does it work? Simply put, the structure of executables and jar/zip archives makes this possible. An executable has all of the "important stuff" at the front of the file, so you can attach any amount of junk (or a jar file) onto the end of it. A jar (or zip) file on the other hand, has all of the "important stuff" at the end of the file. So, by combining the two, the executable portion can execute without problems and the executable can also be used as an archive on the class path (assuming that Sun doesn't start checking for "correct" file extensions). Enjoy!