I'm using "gcj" to experiment while I'm learning. I'm not new to programming in general but I am new to Java. Java is the first langauge I've programmed in which is not an interpreted language.
I managed to create a basic app with 10 or so classes all directly coded into 1 file. It worked.
Now, I was to break the classes into their own files and put them into a package. I'm pretty sure I've got it close to being right because at first I forgot to declare my class as public and I got errors when compiling.
Now when I compile I get this error (command used to compile also shown for reference):
[d11wtq@pc-cac TestApp]$ gcj --main=App -o runme App.java
/tmp/cc49suIT.o: In function `App::main(JArray<java::lang::String*>*)':
App.java:(.text+0x16): undefined reference to `myPackage::MyClass::class$'
App.java:(.text+0x25): undefined reference to `myPackage::MyClass::MyClass()'
collect2: ld returned 1 exit status
[d11wtq@pc-cac TestApp]$
The paths and code for the files are gievn below:
./App.java
import myPackage.MyClass;
class App
{
public static void main(String args[])
{
MyClass obj = new MyClass();
obj.speak();
}
}
./myPackage/MyClass.java
package myPackage;
public class MyClass
{
public MyClass() {}
public void speak()
{
System.out.println("I'm speaking...");
}
}
Any pointers as to where I'm going wrong? Is it the code or the way I'm compiling it? If both classes are in the one file it works :(
Message was edited by:
d11wtq