Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java files in same dir. but one can't call other

 
pravinth Ganesan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Friends,
I have my java files in a MyJava folder. i set the path by
c:\MyJava>path=.;c:/program files/java/jdk1.5.0/bin/
I can able to compile and run single-stand alone java files in MyJava folder. But whenever i am trying to compile a java files which is also in MyJava folder but which uses/(has code) other java class files in the same folder i am getting compile error - means it can't able to refer the other java class files,which are also in the same MyJava folder.Plz help me.
Thank You!
 
Nicolas Stern
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You must also set the Classpath to the folder in which your classes are stored.

HTH - Cheers - Nic
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't set the CLASSPATH environment variable, you can always supply a classpath on the command line for javac and java:

>javac -classpath . MyClass.java
>java -classpath . MyClass

I know you are just starting in Java, but if you understand a little about XML, using Ant as a build tool will be a big help. Eventually most people end up using IDEs, but its still good to be able to use Ant.
 
pravinth Ganesan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Friends.
Now its working after setting the classpath.
Thank You guys. Thanks for your help!

Note:I am not new to java!
i forgot about this classpath.
[ February 17, 2006: Message edited by: pravinth Ganesan ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic