This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes setting classpath (In different drives) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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
Bartender

Joined: Aug 16, 2005
Posts: 12911
    
    3

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 7 API documentation
Scala Notes - My blog about Scala
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.
     
    I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
     
    subject: setting classpath (In different drives)
     
    Similar Threads
    confusion about classpath
    A pain in the ......Please help?
    Setting up Tomcat 3.2.3 on win me
    Classpath Problem
    catlle drive oop-1 to 4