For Linux and Mac OS: Edit ~/.profile or ~/.bash_profile (or /etc/profile for system-wide setting) to include the following line at the end of the file:Įxport CLASSPATH=.:path1/xxx.jar:path2/yyy.jar The entries are separated by colon ( : ).jar ", where the entries are separated by a semi-colon ( ). For Windows, set the CLASSPATH in Control Panel ⇒ System ⇒ Advanced system settings ⇒ Advanced ⇒ Environment Variables ⇒ System Variables ⇒ New ⇒ In "Variable name", enter " CLASSPATH " ⇒ In "Variable value", enter ".If you set the CLASSPATH, you must also include the current directory (denoted as ". CLASSPATH may contain directories (of Java classes) or JAR files (single-file archive of Java classes). You can also include all the JAR files in the CLASSPATH environment variable.You can print its contents via (System.getProperty("")). The location of JDK's extension directories is kept in Java's System Property " ". For Ubuntu, the JDK extension directories are " /jre/lib/ext " (e.g., " /usr/user/java/jdk1.8.0_xx/jre/lib/ext ") and " /usr/java/packages/lib/ext ".For Mac, the JDK extension directories are " /Library/Java/Extensions " and " /System/Library/Java/Extensions ".For Windows, the JDK extension directory is located at " \jre\lib\ext " (e.g., " c:\Program Files\Java\jdk1.8.0_xx\jre\lib\ext ").Copy all the JAR files of the external packages to the Java's Extension Directories (NOT applicable to JDK 9).To include external JAR files, you can either: During execution, you will get a runtime error "Could not find or load main class xxx " or " NoClassDefFoundError ".During the compilation, you will receive compilation error "cannot find symbol" on classes belonging to the external packages.If external JAR files are not properly included: Need to revise this section for JDK 9.Įxternal Java packages (such as Servlet, MySQL Connector/J, JOGL, JUnit) are often distributed in JAR files (Java Archive - a single-file package of many Java classes), with possibly Native Libraries (". JDK 9 introduces a new level called "module" on top of package, and " jmod " files for Java modules. Notes : This section is applicable to JDK prior to JDK 9. (Advanced) External JAR Files and Native Libraries
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |