• 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

compile multiple class files

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to compile my class files. I have two classes. when I compile them i get the following error:
c:\java\test\src>javac MyTest.java
MyTest.java:6: cannot resolve symbol
symbol : variable Test
location : class MyTest
String t = Test.gethelp();
^
1 error
Here is my code:
public class Test
{
public String gethelp()
{
String test = "time";
return test;
}
}
public class MyTest
{
public static void main(String[] args)
{
String t = Test.gethelp();
System.out.println("THe word is " + t);
}
}
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's odd. The javac compiler should look for such class dependencies automatically. Since it isn't, you should simply compile Test.java first, then compile MyTest.java. You can even do this all with one command:
javac Test.java MyTest.java
HTH
Layne
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getHelp is not a static method of Test so you can't execute it the way you are trying to.
Do this:
Test test = new Test();
String t = test.getHelp();
 
Can you hear that? That's my theme music. I don't know where it comes from. Check under this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic