Jar Compiler Help Page

The compiler page allows the user to define the following.

Creating a .jarc file

To create a .jarc file use the New->Other...->Jar Compiler menu option.

To build the .exe, right click on the .jarc file and use Jar Compiler->Compile menu option.

To compress the .exe, right click on the .jarc file and use Jar Compiler->Compress menu option.

Note: A few people report that they do not see the Jar Compiler menu option but if they install a fresh copy of Eclipse it appears. I can not reproduce this issue, so until I can please try a fresh install of Eclipse.

Jar Files

The jar files that go into the 'Jar Files to Compile' list must have an extention of .jar and have compiled Java .class files inside. Any .jar file that does not have any .class files does not need to be compiled but they must be installed with the executable file so that your application can find the resources in the jar file.

The blue arrow buttons at the bottom of the compile list is used to change the compile order of the jar files. You can also right click on a jar file and move it to the top or bottom of the list.

The order that jar files are compiled can be important. Normally your jar file is at the bottom of the list and all other jar files are above it.

Example: jarfileA.jar uses a support jar file called jarfileB.jar, The jarfileA.jar will need to be below the jarfileB.jar in the list.

DLL Files

The DLL files that are to be associated to the executable. The DLL files are needed by the compiler to build an executable that will load DLL files as needed by your application.

An example would be the SWT jar file needs DLLs called swt-win32-3349.dll and swt-gdip-win32-3349.dll to work correctly. Any file in the Jar Files list that has a DLL file associated with it must be added to the DLL Files list.

Resources

The resource section allows the linking of resource files into the executable. This is mainly used to add a ICON type file to be used as the programs desktop icon.

The first .ico type file in the resrouce list will become the compiled programs desktop icon. Other types of resources can be defined but will leave that up to you to learn about. Mainly because I do not understand them well enough and I do not know how they can be used in a Java program.

Not much online help is out thier on resource types but I have found 2 places and they are Defining Windows Resources, Wiki Windows Resouces

If you have a better source than the above websites please email them to me and I will include them here.

Link Paths

The Link Paths list contains directory paths needed by the compiler to find libraries (.lib) type files. This is so the compiler can resolve any references to functions or variables not defined with in your applicaiton but are needed by other jar files, DLLs and libraries.

An example would be the lua5.1.lib file is needed by the luajava-1.1.jar and luajava-1.1.dll files to resolve references and find functions used in the luajava library.

Exe Name

This field is used to define the executable name that is created with in the Build Directory. Can be any name but should have an exetention of .exe

Class Name

This field is used to define the Class that contains the 'main' method, like 'com.MyMain'

Clicking the Class button will display a dialog of all defined main class methods.

How the dialog determines what method is a main class is by looking in the manifest.mf file and looking for either the text 'Main-Class:' or 'Bundle-Activator:'

If your jar file does not contain a manifest.mf file then you have to determine the main class yourself :(

Mayebe some day I will look in the .class files and pull all method names if a manifest.mf file is not found.

Console Checkbox

If this checkbox is checked then the executable will display a console window when it is executed. This can be useful as a method of debugging your application. Any text your application writes to standard out or standard error will show up in the console window. This is mainly used to debugging your program and should not be used for production releases.

Build Directory

This field is used by the compile option to build the executable. All jar files and DLL files are copied to this directory and compiled and linked. This is were the executable will be on a successful compile.

This directory also will contain the makefile called jarc.mk.

Cache Jar - Menu option

To see the popup menu, right click in the 'Jar Files to Compile' list box.

Click to enlarge.

Caching a jar file allows Jar Compiler to use a cached version of the compiled jar file instead of recompiling the jar file.

If you right click an item in the Jar Files listbox a menu appears and one of the options is 'Cache Jar'. Clicking this menu option brings up a dialog that allows you to select a directory to place the compiled jar file into. The best way IMO is to create a new directory in the Jarc install directory to hold the cached jar file. On a successful compile and linking of the executable, then all jar files selected to be cached will be cached and copied to that directory.

Thier is no need to tell Jar Compiler to cache a jar file each time you come into the editor, it remembers which files you have selected in the past to cache. The only way to stop Jar Compiler form caching a jar file is to

If the orignal jar file is changed and has a newer date than the cached jar file then it will be recompiled instead of using the cached version.

Removing the cached jar file (.jar) and the compiled jar file (.t) from the cached directory will cause Jar Compiler to recompile and cache it agian.

Jar Compiler Preference Page

Click to enlarge.

The Jar Compiler Directory field points to the install path of the Jar Compiler.

The GCC Directory field points to the bin directory of the Mingw install within the Jar Compiler install path.

The Debug Mode checkbox causes the Jar Compiler to produce a little more output than normal.

The Compress excutable checkbox will cause the executable that was built to be compressed. This compression does not save runtime executable memory but instead saves disk file size. The executable will expand when executed so you may see a short delay before program starts. I have seen my executables go from 22mb to 5mb in size with the default settings.

For documentation on the upx program read the docs in the Jarc/upx direcotory.

Makefile

The Makefile tab at the bottom of the Jarc window is used to view the makefile text.

Click to enlarge.

If you right click on the makefile text a popup menu will allow you to save the text to a file name, also can enable or disable text wrapping.

The makefile is also in the Build Directory of your project, called jarc.mk. Warning, this file changes only when you tell Jar Compiler to compile the jar, so if you make a change and do not compile the jar then the jarc.mk file in the Build Directory will not be up to date.

The makefile once saved to a file can be used to compile the jar files using the Windows command shell. (cmd.exe in the system32 directory on an XP system)

If executing the makefile using a command shell then be sure that the PATH environment contains the Jar Compiler bin directory, normally C:\Program Files\Jarc\Mingw\bin directory.

Tips

Determining what .jar and .dll files are needed.

This is not an easy task but can be made easier by looking at the error messages. The error messages tell you what methods are missing but not were they are defined at.

If a .jar file requires a .dll then they normally have simular names and sometimes are in the same directory.

The .jar files needed can be detrimined by looking at all source files, if you have access to them from the import statement.

If you do not have the source then all you may have to go on is the error messages in the Jar Compiler output.

A web site that finds jar files based on a class path can be found below, it helps a lot.

Jar finder

Compiling jar files once.

A jar file that does not change and takes a long time to compile can be compiler once and saved for all future compiles.

Compile your jar files as normal, when done look in the Build Directory defined in the Build directory field..

Their should be a .t file of your .jar file. Create a directory in your Jar Compiler directory, default is C:\Program Files\Jarc, and place both .jar and .t file in this directory.

Then make sure that the .jar file in the 'Jar Files to Compile' list points to the new .jar file in the C:\Program Files\Jarc\??? directory..

As long as the .t jar has an earlier date and time than the .jar file Jar Compiler will not recompile it.