GeeCON Prague 2014*
The moose likes Java in General and the fly likes a simple doubt - but ...... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

a simple doubt - but ......

Arul Jose
Ranch Hand

Joined: Jan 14, 2005
Posts: 131


here is file1.java

public class file1{
public static int i=5;
}


here is file2.java

class file2{
public static void main(String args[])
{
System.out.println("value of i = "+file1.i);
}
}

both are in the same directory(folder). i compiled file1.java first. it got compiled. then i compiled file2.java. i get the following message.

C:\Documents and Settings\Aruljose\Desktop>javac file1.java

C:\Documents and Settings\Aruljose\Desktop>javac file2.java
file2.java:4: cannot resolve symbol
symbol : variable file1
location: class file2
System.out.println("value of i = "+file1.i);
^
1 error

please answer if you can

jose.



Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

You've probably got your CLASSPATH environment variable set, and it doesn't include "." to stand in for the current directory. Have a look at this document for info about CLASSPATH.

If you're having this sort of problem, I recommend not having CLASSPATH set at all.


[Jess in Action][AskingGoodQuestions]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Please don't post duplicate questions in multiple forums -- it just wastes people's time, as this one has wasted mine. Further followups here, please.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: a simple doubt - but ......