• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CLASSPATH

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!!
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a read of this, it might help.
 
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic