Zelix KlassMaster - Documentation

The classpath Statement

The ZKM Script classpath statement sets the classpath that will be used by Zelix KlassMaster™. Zelix KlassMaster™ uses its classpath to find all classes:
  • directly or indirectly extended or implemented by the classes you have opened,
  • that are specified in the signatures of any methods in the classes you have opened.
Note that Zelix KlassMaster™ will look inside of any archives appearing in your classpath statement and recursively add any embedded archives to the effective classpath. So, if you have an archive myJar.jar in your classpath statement which contains another archive named embedded.jar then both myJar.jar and embedded.jar will be in the effective classpath.

Note also that the classes you have opened within Zelix KlassMaster™ do not have to appear in its classpath.

Also, the Java bootstrap classes should appear in whatever classpath you set. If your classes were compiled using the JDK 1.1 then the path to the JDK 1.1 classes.zip must appear in your classpath. If you used the JDK 1.2 or better then the path to the corresponding rt.jar should appear in your classpath. If you used the JDK 1.9 then the path to the corresponding jrt:/ file system should appear in your classpath. See the example below. If you do not specify a path to any bootstrap classes then Zelix KlassMaster™ will automatically append the path to the bootstrap classes associated with the JVM you are using to run Zelix KlassMaster.

In the absence of any classpath statement, the classpath will be set to whatever the classpath was when Zelix KlassMaster™ was started.

Multi-release JAR files

If you have a multi-release JAR file then you may need to specify different classpaths that are specific to particular Java versions. You can do this by having additional separate classpath statements that specify the relevant Java version number immediately after the classpath keyword. Please see the example below.

Examples

In the Windows™ environments

Prior to Java 9:
classpath "." 
          "c:\jdk1.8.0\jre\lib\rt.jar"
          "c:\lib\*.jar";
OR
classpath ".;c:\jdk1.8.0\jre\lib\rt.jar;c:\lib\*.jar";
For Java 9 or better:

classpath "." 
          "c:\JDK\jdk1.9.0\lib\jrt-fs.jar"
          "c:\lib\*.jar";
OR
classpath ".;c:\JDK\jdk1.9.0\lib\jrt-fs.jar;c:\lib\*.jar";

In a Unix environments (including Mac OS X)

Prior to Java 9:
classpath "." 
          "/opt/jdk1.8.0/jre/lib/rt.jar"
          "/lib/*.jar";
OR
classpath ".:/opt/jdk1.8.0/jre/lib/rt.jar:/lib/*.jar";
For Java 9 or better:
classpath "." 
          "/opt/jdk1.9.0/lib/jrt-fs.jar"
          "/lib/*.jar";
OR
classpath ".:/opt/jdk1.9.0/lib/jrt-fs.jar:/lib/*.jar";

As shown above, you can break the classpath up into independent, quoted Strings without using ";" or ":" separators. This syntax is platform independent and is recommended.

Multi-release example

In the example below, all three classpath statements would appear in the same ZKM Script. However, the statements specifying a Java version number (e.g. 9 or 10 in this case) would only be applied when analyzing the corresponding multi-release versions of particular classes.
//Default specifies no Java version
classpath "/opt/jdk1.8.0/jre/lib/rt.jar";

//Classpath specific to Java 9 multi-release classes
classpath 9 "/opt/jdk1.9.0/lib/jrt-fs.jar";

//Classpath specific to Java 10 multi-release classes
classpath 10 "/opt/jdk1.10.0/lib/jrt-fs.jar";

Syntax

"classpath" [versionInteger] ("\"" classpathString "\"")+ ";"

classpathString ::= path (pathSeparator path)*

Where:
  • path is a file system path specifying a folder or archive file,
  • pathSeparator is the character returned by System.getProperty("path.separator") by the JVM running Zelix KlassMaster (E.g. ';' for Windows) and
  • versionInteger is an optional integer (greater than 8) indicating the Java version to which this classpath statement pertains (E.g. 9, 10, 11, etc.).

Any path can contain the "*" wildcard in its final file qualifier. Also, a wildcard may appear in the final directory qualifier. See the examples below.
classpath "directory0/*.jar"   //All JAR files in directory0
          "directory1/*/*.jar" //All JAR files in sub-directories of directory1
          ; 
 
The ZKM Script Language ZKM Script ignoreMissingReferences statement
Zelix KlassMaster - Java Obfuscator