• Post Reply Bookmark Topic Watch Topic
  • New Topic

CLASSPATH  RSS feed

 
Daniel Gultom
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I encountered some problem with the classpath in Java. I am a really beginner in this language, so please use less jargon...
I create two classes in two different .java files
These are the classes:
Welcome.java
------------
class Welcome {
public static void main ( String[] args ) {
printWelcome();
}
public static void printWelcome () {
System.out.println("Welcome to Java");
}
}

Now, next class in different file need to access the Welcome class
AccessWelcome.java
-----------------
class AccessWelcome {
public static void main ( String[] args ) {
Welcome well = new Welcome();
well.printWelcome();
}
}

I tried to compile the AccessWelcome.java using javac AccessWelcome.java, but there is this message about classpath...
What i am trying to do is to use AccessWelcome class to call a method in Welcome class..

Thank you in advance for your kind explanation!!!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a read of this, it might help.
 
Red Smith
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Java 1.5 on Sun Solaris 8 and I was able to compile and run

/home/xyz/code/java/> java Welcome
Welcome to Java
/home/xyz/code/java/> java AccessWelcome
Welcome to Java


both files with no modifications (I didn't know you could have a 'public static void main()' in both and have it work). I checked my CLASSPATH variable and it says I don't have one set?!?!

Could you post the exact compiler output messages you are getting?

Do you have the classes in the same directory and is it the current directory?
[ August 06, 2007: Message edited by: Red Smith ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!