Java Reference
In-Depth Information
The destination directory for the custom JRE contains several files and sub-directories. You can list them as follows:
[/home/ksharan]$ ls compact1jre
bin COPYRIGHT README THIRDPARTYLICENSEREADME.txt
bom lib release Welcome.html
The bin directory contains the java command that you will use to run your Java classes. The following command
shows the version of the JRE created:
[/home/ksharan]$ ./compact1jre/bin/java -version
java version "1.8.0"
Java(TM) SE Embedded Runtime Environment (build 1.8.0-b132, profile compact1, headless)
Java HotSpot(TM) Embedded Minimal VM (build 25.0-b70, mixed mode)
Notice that version information for the JRE also contains the profile name, which is compact1 in the output.
Listing C-3 contains the code for a HelloCompact1 class that has dependency on the compact1 profile.
Listing C-3. A HelloCompact1 Class That Uses Classes from Only the compact1 Profile
// HelloCompact1.java
package com.jdojo.profiles;
public class HelloCompact1 {
public static void main(String[] args) {
System.out.println("Hello, compact1 profile!");
}
}
Assuming that the HelloCompact1 class is copied to the /home/ksharan/classes directory with its package
structure, the following command uses the compact1 profile to run the class:
[/home/ksharan]$ ./compact1jre/bin/java -cp /home/ksharan/classes com.jdojo.profiles.HelloProfile
Hello, compact1 profile!
Recall that the RowSetTest class uses the compact3 profile. Running the class using the compact1 profile via the
following command generates a runtime exception, as shown in the output:
[/home/ksharan]$ ./compact1jre/bin/java -cp /home/ksharan/classes com.jdojo.profiles.RowSetTest
Exception in thread "main" java.lang.NoClassDefFoundError: java/sql/SQLException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
 
Search WWH ::




Custom Search