The secret of creating an EXE file using jbuilder9 is not disclosed

Source: Internet
Author: User
JBuilder does not support local compilation. However, there is a hidden technique that allows you to start a Java program from an executable file, which can appear or does not appear in the console window. Jbuilder.exe jbuilderw.exe (optional) JBuilder. config.
JDK. config javalauncher. DLL cmdjbuilder.exe is a common executable shell file used to start Java programs. "jbuilderw.exe" is the same as javaw.exe. It wraps "jbuilder.exe" and does not display the conso le window during running. The key to using these files is the file name. "Jbuilder.exe" looks for a configuration file named "JBuilder. config", which contains the required information to run the Java program.
Similarly, "jbuilderw.exe" finds "jbuilder.exe" to start Java programs without the console window. If you rename "jbuilder.exe" to "foo.exe", "foo.exe" looks for "foo. config "configuration file. Similarly," jbuilderw.exe "is renamed to" foow.exe ", which searches for the" foo.exe "file.
How can I use jbuilder.exe to start an application? (Or the renamed EXE file) to start the Java application.

The following is an example:

Borland JBuilder 8 is installed in the E:/jbuilder8/directory, and a tempdirectory is created under E:/jbuilder8/bin/. Then, jbuilder.exe and JBuilder are created. config, javalauncher. DLL, JDK. copy the four files in config to the E:/jbuilder8/bin/temp/directory, create a hello directory under the directory, and generate a hello. java file, that is, E:/jbuilder8/bin/temp/Hello/hello. java file,

// Hello. Java
Package hello;
Public class Hello {
Public static void main (string s []) {
System. Out. println ("Hello, EXE file! ");
}
}

Compile the Java file, open the JBuilder. config file, and modify the file accordingly:

Find the following two lines in JBuilder. config:

# Start JBuilder using the its main class
Mainclass com. Borland. JBuilder. JBuilder

To:

# Start JBuilder using the its main class
Mainclass hello. Hello
Addpath E:/jbuilder5/bin/temp/

The addpath command adds the directory to the class path. The commands that can be identified by other config can be found in config_readme.txt in the JBuilder/bindirectory.

Then, modify the javapath in JDK. config to the relative path. For example, the original path is:

Javapath ../jdk1.4/bin/Java

Modify:

Javapath.../../jdk1.4/bin/Java

Modify jbuilder.exeand jbuilder.configto the corresponding file name, for example, foo.exe and foo. config.

So far, modifying JBuilder to use the EXE file to start your Java application has been completed, but the fun is not in this place. The following tips may be more interesting, package the JAR file into the EXE file!

Assume that the above file is used to generate the hello. jar package and the execution process is as follows:

Jar CVF hello. Jar Hello/*. Class

The class file is packaged into an EXE file, and then the jarpackage is appended to jbuilder.exe. the execution process is as follows:

Copy/B ../jbuilder.exe + hello. Jar foo.exe

Convert a jar file to an EXE file

In the foo. config (JBuilder. config) file, remove the previously added class path and add the following path:

Addpath E:/jbuilder5/bin/temp/foo.exe

Run: foo.exe and you will see that an EXE file containing the jar package has been executed!

The general principle of this process is: the important information of the EXE file is in the file header, so it doesn't matter to put the mess at the end of the EXE file; the important information of JAR/ZIP files is at the end of the file, so that they are irrelevant and can be easily executed.

However, to use this function, you have to bear the risks that may arise, Because Borland does not provide official support for this function!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.