Java IDE-use Jbuilder to create exe files

Source: Internet
Author: User

If you think that jb really provides a mainstream method to package a java application into an exe file after you see the title, you will be disappointed. The following tips are just a trick.

This is borland's non-public usage technique. It can use jbuilder to create exe files to start java files. 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. To do this, you need these files in the bin directory of jbuilder:

Jbuilder.exe

Jbuilderw.exe (optional)

Jbuilder. config

Jdk. config

Javalauncher. dll

Container, but the console window is not displayed during running. The key to using these files is the file name. “Jbuilder.exe "searches for a configuration file named" jbuilder. config ", which contains the required information for running java programs. In the same example, jbuildercmdexe‑ jbuilder.exe "is used to start java programs without the console window. Hosts file.

In this case, the intelligent reader should guess how to use jbuilder.exe to start the application. (Or the renamed exe file) to start the java application. The following uses the local machine as an example.

Borland jbuilder 5 is installed in the e: jbuilder5 directory, and a tempdirectory is created under e: jbuilder5in. then, jbuilder.exe and jbuilder are created. config, javalauncher. dll, jdk. copy the four files in config to the jbuilder5in emp directory, create a hello directory under the directory, and generate a hello. java file, that is, e: jbuilder5in emphellohello. java file, file: // hello. java/package

Hello;

Public class hello {

Public static void main (string s []) {

System. out. println ("hello, exe file! ");

}

}

Open the jbuilder. config file and modify it accordingly:

Find the following two lines in jbuilder. config:

# Start jbuilder using the its main class

Mainclass com. borland. jbuilder. jbuilder

Change

# 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 a relative path. For example

Javapath ../jdk1.3/bin/java

Modify

Javapath.../../jdk1.3/bin/java

Last

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

Run the foo.exe file.

So far, modifying jbuilder to use the exe file to start your java application has been completed.

But the fun part is not here. 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 execute the process.

Jar cvf hello. jar hello *. class

Package class files into exe files

Then, add the jarpackage to the end of jbuilder.exe.

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

Then execute.

  

Have you seen it? An exe file containing a jar package is 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; while jar/zip

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.