• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

classes in same folder, but not compiling

 
Priyha Jootu
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
This is a very basic question, but not sure why this compile error.I have 2 java files named hello1.java and hello2.java in same directory named c:\epal_sts\code\
I am calling the method of hello2 class from hello1.
But when i compile hello1.java, it says this error:
C:\EPAL_STS\code>javac hello1.java
hello1.java:8: cannot resolve symbol
symbol : class hello2
location: class hello1
hello2 h2 = new hello2();
^
hello1.java:8: cannot resolve symbol
symbol : class hello2
location: class hello1
hello2 h2 = new hello2();
^
2 errors
The 2 files are:



Is there anything wrong here? Please let me know why the compile error comes.
Thanks
priyha
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've probably got an explicit setting for the CLASSPATH variable that doesn't include an entry for "." (dot,) the current directory. If you don't specifically need to set the CLASSPATH (and as a beginner, you don't) then don't; the default setting would work fine here.
CLASSPATH is an environment variable -- the proper way to set it or check it is system-dependent.
 
Priyha Jootu
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i was working with some other java code, i had to creat a new variable classpath in the environment variable settings. But i didn't include the . (same directory) in it. Now i added the . in the classpath and the program hello1.java compiles fine.
Thanks a lot
priyha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic