This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

a simple question, but......

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.



 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you have the current dircetory in your classpath? The easiest way is make 'dot' the first entry on your classpath ie classpath=.;etc;etc2 (colons for *nix) Including the dot on the classpath is not always the best idea, but usually by the time it's a problem you know enough to manage.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
make sure that your classpath includes your current directory
by adding .; to your classpath variable
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!