aspose file tools*
The moose likes Beginning Java and the fly likes classpath issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "classpath issue" Watch "classpath issue" New topic
Author

classpath issue

Siva kandasamy
Ranch Hand

Joined: Dec 31, 2002
Posts: 139
Hi There,
See below, CASE(2) and CASE(2). Do you see any reasons why I sould get this error.
Let me know, if you have more questions.
Thanks
siva
~/reading/java % echo $CLASSPATH
.:/home/siva/program/java/jaxp1.0.1/jaxp.jar:.:/home/siva/program/java/jaxp1.0.1/jaxp.jar

CASE(1):
---------
~/reading/java % javac LibTest.java

CASE(2):
---------
~/reading/java % javac -classpath "/home/siva/reading/java/com/siva/simple2" LibTest.java
LibTest.java:19: package com.siva.simple2 does not exist
import com.siva.simple2.*;
^
LibTest.java:34: cannot access List
bad class file: /home/siva/reading/java/com/siva/simple2/List.class
class file contains wrong class: com.siva.simple2.List
Please remove or make sure it appears in the correct subdirectory of the classpath.
List l = new List();
^
2 errors

CASE(3):
---------
~/reading/java % javac -classpath ".:/home/siva/reading/java:/home/siva/reading/java/com/siva/simple2:" LibTest.java
LibTest.java:34: cannot access List
bad class file: /home/siva/reading/java/com/siva/simple2/List.class
class file contains wrong class: com.siva.simple2.List
Please remove or make sure it appears in the correct subdirectory of the classpath.
List l = new List();
^
1 error
~/reading/java %
//********** LibTest.java ********** //
import com.siva.simple2.*;
public class LibTest {
public LibTest(){
System.out.println("LibTest()");
}
public static void main(String[] args) {
LibTest lt = new LibTest();
List l = new List();
Vector v = new Vector();
}
} ///:~
//********** List.java ********** //
package com.siva.simple2;
public class List {
public List() {
System.out.println("com.siva.simple2.List");
}
public static void main( String[] args ){
List l = new List();
}
} ///:~
//********** Vector.java ********** //
package com.siva.simple2;
public class Vector {
public Vector() {
System.out.println( "com.bruceeckel.util.Vector123");
}
} ///:~
[ March 23, 2003: Message edited by: Sivanantham kandan ]
Amol Desai
Ranch Hand

Joined: Jan 29, 2003
Posts: 82
Hi,
You need to set the current directory(reading/java) to the classpath so that
compiler can the class com.siva.simple2.... which is inside the current directory.
Hence you need to specify it has
~/reading/java % javac -classpath ".:/home/siva/reading/java/com/siva/simple2" LibTest.java
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: classpath issue