- Code: Select all
package testing;
public class Class2 {
private int i;
public Class2(int i) {
this.i = i;
}
public int getI() {
return i;
}
}
The above class is used by this class
- Code: Select all
package testing;
import lejos.nxt.LCD;
import lejos.nxt.Button;
public class Class1 {
public static void main(String args[]) {
Class2 c2 = new Class2(42);
int i = c2.getI();
LCD.clear();
while(!Button.ESCAPE.isPressed()) {
LCD.drawInt(i, 4, 2);
LCD.refresh();
}
}
}
Now, if I nxjc compile Class1 I get the following:
Class1.java:9: cannot find symbol
symbol : class Class2
location: class testing.Class1
Class2 c2 = new Class2(42);
I have tried nxjc Class2.java first, which seems fine, but compilation of Class1 cannot complete.
I have also tried nxj Class2 but that doesn't work since Class2 doesn't have a main method. I would really not like to hack it with an empty main().
How do I compile my program so Class1 knows Class2?
Thanks

