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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "setting classpath (In different drives)" Watch "setting classpath (In different drives)" New topic
Author

setting classpath (In different drives)

nirmal Rchavan
Ranch Hand

Joined: Jul 10, 2007
Posts: 35
Hi All,
Please help me solve this classpath setting
Here's the scenerio

i have a class in D:\WorkSpace\myProgram\Test.java

public class Test extends SeniorTest {
//some code goes here
}

i have a class in C:\Temp\SeniorTest

public class SeniorTest {
}

when i compile the Test class i get a compilation error(canot find symbol:class SeniorTest)
i set the classpath in this way
>set CLASSPATH=c:\Temp
i also tried with
>javac -claspath c:\Temp

i could'nt solve this
1) let me know if this is possible
2) am i setting the classpath correctly using the command-line and how to do the same using environment variable.

Appretiate your Time and help..
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14420
    
  23

Did you compile SeniorTest.java? You need to compile it first, otherwise the Java compiler can't find class SeniorTest when you compile your class Test. Try this:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Jan van Mansum
Ranch Hand

Joined: Oct 19, 2007
Posts: 74
  • If SeniorTest is in a different package than Test, don't forget to import it.
  • Use the -sourcepath option to specify where javac can find all the sources and use -d to specify where the .class files should be saved


  • Example (cd to D:\WorkSpace\myProgram)

    Strange though that Test is a subclass of SeniorTest as I should think that Test is a more generic concept than SeniorTest. Shouldn't it be the other way around?

    Also, note that classpath is spelled with two letters s. (Although in this example you do not need to set the classpath.)

    [ November 22, 2007: Message edited by: Jan van Mansum ]
    [ November 22, 2007: Message edited by: Jan van Mansum ]

    SCJP 1.4, SCWCD 1.4
    nirmal Rchavan
    Ranch Hand

    Joined: Jul 10, 2007
    Posts: 35
    Point taken Sire..
    My mistake, i was usnig two command prompts, and i was running one of the class in a package and the other as default.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
     
    subject: setting classpath (In different drives)