'클래스패스'에 해당되는 글 1

  1. 2009.11.13 java, javac 명령어

java, javac 명령어

src> "C:\Program Files\Java\jdk1.6.0_12\bin\javac" com/test/sample/Test.java
src> java com.test.sample.Test
Hi
src> "C:\Program Files\Java\jdk1.6.0_12\bin\javac" com/test/sample/Test.java
com\test\sample\Test.java:5: package org.apache.log4j does not exist
                org.apache.log4j.Logger logger;
                                ^
1 error

src> "C:\Program Files\Java\jdk1.6.0_12\bin\javac" -cp D:\lib\log4j-1.2.13.jar  com/test/sample/Test.java
src> java com.test.sample.Test
Hi
src> "C:\Program Files\Java\jdk1.6.0_12\bin\javac" -cp D:\lib\log4j-1.2.13.jar  com/test/sample/Test.java
src> java com.test.sample.Test
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
        at com.test.sample.Test.main(Test.java:5)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        ... 1 more

src>java -cp D:\lib\log4j-1.2.13.jar  com.test.sample.Test
Exception in thread "main" java.lang.NoClassDefFoundError: com/test/sample/Test
Caused by: java.lang.ClassNotFoundException: com.test.sample.Test
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: com.test.sample.Test.  Program will exit.

src> java -cp D:\lib\log4j-1.2.13.jar;.  com.test.sample.Test
Hi