aspose file tools*
The moose likes Beginning Java and the fly likes compilation problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compilation problems" Watch "compilation problems" New topic
Author

compilation problems

ven kumar
Greenhorn

Joined: May 27, 2003
Posts: 3
I'm having some troubles compiling java source files from command prompt.
I have class1.java and class2.java in package app. So, I created a directory named "app", put "Class1.java" and "Class2.java" in that directory. Class2.java is a simple java program with one method (method2) to print some message on the console when executed. I'm trying to access method 2 of Class2 from Class1. When I try to compile it, it is giving me compilation errors that "Can not resolve symbol Class2". Any help is appreciated.
Thanks
Kumar
Susilo Saja
Ranch Hand

Joined: May 27, 2003
Posts: 91
It mean the jvm can't find class2
have you put "app" directory in the CLASSPATH? or have you define the package name for class1 & class2?
Dhamodharan Krishnan
Greenhorn

Joined: Nov 07, 2001
Posts: 23
Hi Ven Kumar,
From the info that you have given, let me guess that your classes are like this
-----------------------------
package app;
public class Class1
{
Class2 c2;

public Class1()
{
c2 = new Class2();
c2.method2();
}
public static void main()
{
Class1 c1 = new Class1();
}
}
---------------------------------
package app;
public class Class2
{
public Class2
{
}
public void method2()
{
System.out.println("I am method2 speaking!");
}
}
-------------------------------------
Both these classes are in app directory.
Let me assume that you have the Java files in
D:\Dev\app folder
Please go to D:\Dev folder
From D:\Dev, try compiling Class2 first.
Then compile Class1
Then run Class2.
It should work fine.


Dhamodharan Krishnan,<br />Sun Microsystems, Bangalore<br />Direct : 91-80-4184 7247<br />Cell : 91-99 80 147 600
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compilation problems
 
Similar Threads
ant-classpath- FileNotFoundException
Creating an instance of a sub-class runs parent and child constructors?
How to invoke a grand-parent method?
Package & Compilation Problem
compiling a package with javac vs eclipse (cannot find symbol)