I think most of the Java beginners will encounter the problem, that is how to configure the environment, the implementation of Java-jar Xxx.jar will be reported Noclassdeffinderror, I began to learn at the time, also encountered these problems.
1.path Path is the meaning of the road, we directly in the console run a program, the system will be in the specified path down to find out if there is no this program, if there is to execute, no error or hint. In Windows systems, use echo%path% to view paths under Path on Linux systems, using echo $PATH After we add the Java Bin directory to the path, we can execute it directly in the control input Java command, without having to execute the relevant Java command in the bin directory into Java. 2.CLASSPATH By setting the path, you can execute Java commands in any directory, but how does the JVM know where I'm going to execute the class? This will be solved by setting up classpath. Several ways to set classpath variables: 1). Set 2 through the Environment Variables window). command line setup Set Classpa th= 3). Setting up the Java command java-classpath= Our most commonly used configuration is to set the classpath=.; means to find the class in the current directory. The previous version also had to set Lib and Lib\tools.jar, now I use the JDK1.8 found that I can not set up, the system to help you set up and complete the class search. We can use the following program to see what the system is loading by default jar url[] Urls=sun.misc.launcher.getbootstrapclasspath (). Geturls (); for (int i = 0; i < urls.length; i++) { &NBSP;SYSTEM.OUT.PRINTLN (URLs [I].toexternalform ()); } &NBsp; Rt.jar is the core Java jar package, basically contains the basic classes we usually use classpath for the JVM is equivalent to path corresponding to the operating system, The operating system will find the program at the specified path, and the JVM will find class at the specified path
Re-learning Java Basics (i):P Ath and classpath