wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes compile multiple class files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compile multiple class files" Watch "compile multiple class files" New topic
Author

compile multiple class files

mark babcock
Greenhorn

Joined: Jun 26, 2002
Posts: 14
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

Joined: Dec 06, 2001
Posts: 3061
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


Java API Documentation
The Java Tutorial
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
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();


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compile multiple class files
 
Similar Threads
Reg. abstract class and method
class file contains wrong class error , i dont understand it so fandmental
I Still Get the Same Compile Error
Why Won't This Simple Program Run?
Why Won't ThisCompile?