ClassPath full solution about Java

zhaozj2021-02-08  224

The most popular Java article in www.dukejava.com

Java's new entry is often more confused to ClassPath. Why is it in the Dongdong that can run in the development environment, or the Dongdong running in the outside, you will die, you are dead! After reading this article, you have no worries (exaggerated) :) Oh Hao Java's advantage is that he is an automatic support network function, raising a simple example to have an application he uses Java.lang. .String (in fact, if there is a program that is not used, it is too difficult to imagine :)), and com.shinechina.myclass (I wrote two versions) These two versions 1: package com.shinechina; public Class myclass {public static void main (string args []) {string str = "version 1: Hello, Welcome to Chinaasp Java technology"; system.out.println (STR);}} version 2: package com.shinechina; public Class myclass {public static void main (string args []) {string str = "version 2: Hello, Welcome to ChinaAasp Java technology"; system.out.println (STR);}} Now I am running it Java COM. SHINECHINA.MYCLASS is now the problem com.shinechina.myclass in C: /, D: /, even in the Alan Brother, Javabeans old brother, there are so stuff on the machine, how do you know how Cool Java knows? Where do he find it, what should he make to assume a version one in c: /mylib/shinechina/myclass.java hypothesis version 2 in D: /MYLIB/SHINECHINA/myclass.java pay attention: Don't forget to compile into CLASS Document, Java file is a CD C: / mylib / com / shinechinajavac * .javacd d: / mylib / com / shinechinajavac * .java has: He first go to the machine ClassPath to find a Windows system C: / MYLIB; D: / MYLIB; D: /JDK1.2.2/Lib/rt.jar; or UNIX system /Home/local/:/usr/local/:/usr/local/jdk1.2/lib/rt.jar is good He found the COM directory under C: / mylib, there is a play, and there is S. Hinechina directory, found myclass.class, ok is him, as for d: / mylib my version 2 Myclass he ignored, as for String is in the RT.jar compression package, he will perform it again. The result is version 1: Hello, Welcome To Chinaasp Java Technology Inverted the path of the D disk in C:, the result of the execution is version 2: Hello, Welcome to ChinaAasp Java technology is pushed, only in the classpath, the first found Calences, you have to control the one that must be implemented: java -classpath d: / mylib;% classpath% com.shinechina.myclass execution result is version 2: Hello, Welcome To ChinaAsp Java technology development environment execution is In this way, there is always a local designated class path.

转载请注明原文地址:https://www.9cbs.com/read-1735.html

New Post(0)