• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

classpath issue

 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic