Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compile multiple class files

 
mark babcock
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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);
}
}
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • 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
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • 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();
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic