PRB: Compiled application cannot find resources
Notice Information in this article applies to Excelsior JET version 4.5 and above. For versions 2.5 through 4.1, see article #14.
The compiled application fails to load resource files (images, icons, etc.) For a GUI application it typically results in improperly displaying the application’s window and controls, and throwing
A Java application running on a conventional JRE typically searches resource files along the classpath. It is a list of directories and jars specified in the
java.class.path property, which in turn may be set using the
-cp) option of the Java launcher (
javaw), or using the
CLASSPATH environment variable.
A JET-compiled application loooks for resource files in exactly the same way. So you have to ensure that resource files will be available to the executable and that the classpath will be properly set at run time.
The problem can arise on both the developer’s system and end-user systems. Thus two typical situations can be observed:
- just after compiling the application to native code, it does not work
- compiled Java application works on the developer’s box but does not work when installed to another system.
Let us consider these cases separately.
The only root cause of the problem on the developer’s system is incomplete application classpath specified (provided that the application works fine on the default JVM). So if you face the problem, first check the classpath for completeness. It can be easily done with Excelsior JET Control Panel: the Classpath pane on the first page of the Control Panel shows the application’s classpath.
Note that you should not experience this problem if you specified correct Command line on the left of this page or used Excelsior JET Launcher to create the project.
However if you edit the classpath manually the problem can arise, so use the manual setting very carefully and check classpath for completeness each time.
When you prepare the application for deployment using the JetPackII tool, the same problem can arise again. Typically, this happens for resource files that reside in directories, not in jar/zip files /The JET Optimizer packs resource files located in jar/zip classpath entries into executable by default. Thus, generally there is no way to forget them to include to the deployment package unless you decided to leave those jar/zip files separate from the executable./ . Classpath entries that are directories are always left separate from executable with all contained resource files. Using JetPackII, you have to add such directories to the package and assign them to respective classpath entries.
As you have freedom over defining the contents of the directories in the package, you might simply forget to include a required resource file. It will be the cause of the problem on a target system. So once you faced the problem, check that you included all needed resource files to the directories assigned to some classpath entries of the executable(s) you deploy. We also strongly recommend you to perform Trial Run on the Step 5 of JetPackII to catch the problem prior to actual deployment.
- Excelsior JET User’s Guide (https://www.excelsiorjet.com/docs), Chapter “Excelsior JET Launcher”.
- Excelsior JET User’s Guide (https://www.excelsiorjet.com/docs), Chapter “Application Considerations”, section “Resource packing”.
- Excelsior JET User’s Guide (https://www.excelsiorjet.com/docs), Chapter “Deployment Automation”, section “Setting Up Standalone Resources and Java System Properties”.
Article ID: 30
Last Revised On: 14-Aug-2006