The Artima Developer Community
Sponsored Link

Java Answers Forum
classpath question

1 reply on 1 page. Most recent reply: Mar 16, 2003 8:56 PM by Kishori Sharan

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
rassuls

Posts: 10
Nickname: rassuls
Registered: Mar, 2003

classpath question Posted: Mar 16, 2003 7:47 PM
Reply to this message Reply
Advertisement
I am confused. Here is the story. I have the following directory structure:
c:\MyDir\check
I have the following two files (Mine.java and Test.java) in c:\MyDir directory.

package check;
public class Mine
{
public int x = 9;
}

import check.*;
public class Test
{
public static void main(String[] args)
{
Mine m = new Mine();
}
}

Here are the steps I follow:
set classpath=.;c:\MyDir;
javac Mine.java
move Mine.class check (I am using MS Windows; moving the .class file into check directory)
javac Test.java
Test.java:6: cannot resolve symbol
symbol : constructor Mine ()
location: class Mine
Mine m = new Mine();
^
1 error

My solution is when I move Mine.java out of c:\MyDir then everything works fine.
Why???


Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Re: classpath question Posted: Mar 16, 2003 8:56 PM
Reply to this message Reply
The problem lies in your CLASSPATh settings. Since your classpath lists current directory (.) first, it checks for Mine.class in current directory first, which is causing the problem. Better move (or keep) the Mine.java somewhere, which is not accessible in CLASSPATH before the actual C:\MyDIR\check . This is solve the problem. Or, you may want to set different class path for compiling the source code and different for running the class. However, the problem lies in your CLASSPATH settings.

Thanks
Kishori

Flat View: This topic has 1 reply on 1 page
Topic: append doc files Previous Topic   Next Topic Topic: Java Calculator application

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use