• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Please explain this classpath

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a .java file on drive c
c:\packageA\ClassA.java
And another file on drive d
d:\packageB\ClassB.java
//******************************************************
//************** ClassA's structure ********************
//******************************************************
package packageA;
public class ClassA{
public static void print(){
System.out.println("ClassA's method print");
}
}

//******************************************************
//************** ClassB's structure ********************
//******************************************************
package packageB;
import packageA.*;
class ClassB extends ClassA{
public static void main(String args[]){
print();
}
}

Can i compile both files simultaneously on d:\ prompt ?
How i will set the class path?
How i will run the ClassB.class (consist main method) file?
Is this right way please guide.
set classpath = c:\jdk1.3\bin;c:\packageA;c:\packageB
d:\packageB\javac ClassB.java
is giving the error in ClassB packageA is not exist.
I am a java programmer but i am not success to solve this problem.
please help me.
Thanks in advance.
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to explicitly indicate your classpath to the compiler. Try
javac -classpath C:\packageA;D:\packageB ClassB.java
(You did say that the packages were on different volumes C&D)
Good Luck!
Rob
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
packages names will be added to each entry in the classpath to look for the classes.
Thus if classpath contains c:\packageA and class ClassA is on packageA that will result in c:\packageA\packageA\ClassA, which is not correct.
Try seeting classpath to c:\
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ugh, yes you're right Jose. my bad....must be 4am ;p
he's got two different packages on two different volumes so he's still going to have to include them individually:
javac -classpath C:\;D:\ ClassB.java
and of course this assumes that your working directory when you call javac is the same directory where the ClassB.java file is.
Rob
[ January 13, 2002: Message edited by: Rob Ross ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic