Re-learning Java Basics (i):P Ath and classpath

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.