Java Classes

The Java Classes panel lets you configure JExpress so it automatically finds classes. You must fill in all the fields on this panel if you're using the auto-find feature. Otherwise, simply click on the Manually radio button and ignore all the other fields in this panel.

Click on the jump point or just page down to learn more about each setting on this panel.

 


 

Find classes

If you'd like JExpress to find the exact classes your application uses, then click on the Automatically button. You will still have to add any classes to the Local Files list which are loaded with the Classes or ClassLoader classes (e.g., forName or loadClass) because there is no efficient way to automatically detect these classes. Also, any interface classes must be specifically included in the implements list; otherwise, the classes won't be found.

If you prefer to simply specify all the classes your Java app or applet uses, then select the Manual option. You'll specify the classes, JAR, and zip files in the Local Files list field. If you select Manually, then you will not be able to access the following fields on this panel: Main class name, Build classpath, and Packages to skip because these fields are only relevant when JExpress finds classes automatically.

 


 

Main class file

This is the name of the class file with the main() function that starts your app. Click on the Search button to select the file, or if your class files are already in JAR or zip format, you can type the file name. For an app your main class file is the file which contains the main() member function that starts your application. For an applet it is the file that extends the Applet class.

 


 

Packages to skip

List the packages that you do not want JExpress to distribute because you know your customers' environment already includes these packages. For example, if your system uses the JRE, then you don't need to include the java, sun, and javax.swing packages with your distribution files.

Be careful not to include packages that your Java app requires that are not standard because your package will throw a class not found error while running.

 


 

Build classpath

The Build classpath should include all the directories, zip files, and JAR files used to build your application on this computer. Remember to organize the classpath in the search order you'd like JExpress to use. You can highlight an item and then use the Up and Down buttons to move an item to a higher or lower search priority.

You set the classpath for your application when it's running on your customer's machine on the JVM panel (click the All sub-tab).

If you're having trouble defining your classpath so JExpress can find all of the classes for your app, then look at the classpath.log to see which class JExpress is analyzing. Be sure to include the classpaths for all of the classes in the import statement.

Let's look at an example. We'll make the following assumptions:

  • You have a Java app named MyApp
  • The MyApp.java file, which contains main(), is part of a package called com.mycompany
  • You keep all of the classes for the package com.mycompany in C:\JavaSource\MyApp. In other words, MyApp.class lives in C:\JavaSource\MyApp\com\mycompany
  • Your app also uses classes from a project, called Subproject. The Subproject does not use packages for its classes. All classes for Subproject are in the directory C:\JavaSource\Subproject\classes
  • You app also uses classes from a second project, called JarProject. The JarProject keeps all of its classes in the file JarProject.jar and that JAR file is in the directory C:\JavaSource\JarProject\JarProject.jar

Here's how your Build classpath would look:

  • C:\JavaSource\MyApp
  • C:\JavaSource\Subproject\classes
  • C:\JavaSource\JarProject\JarProject.jar

Let's look closer why you include C:\JavaSource\MyApp instead of C:\JavaSouce\MyApp\com\mycompany. Obviously, the classes for MyApp are not in C:\JavaSource\MyApp, but in subdirectories of it. You want to include the directory where the package is (i.e., com.mycompany), not where the classes are if classes are part of a package.

On the other hand, you include C:\JavaSource\Subproject\classes instead of C:\JavaSource\Subproject because these classes are not part of a package and the classes themselves are in the classes subdirectory.

If you're unsure how to create the classpath, look at the classpath that you use to compile your application. If you use an IDE, you don't want to include the directories/JAR files for the IDE. You only want to use the portion of the IDE's classpath that specifies where your classes, and any third party projects that your classes use, reside.

Ultimately, you need to look at each of your source files and determine what other classes it uses. You then need to include the JAR/ZIP file that includes those classes or the directory where the classes are (or where the packages are).

If you don't know where the class files are or which packages and JAR/ZIP files they use, then talk with the developer of the package. Or, set the Find classes to manually and simply specify the JAR files and classes on the Files panel.