I have a simple program written in Java:
package edu.oakland.lecture;
public class Alfa {
int a;
public int getAttribute() {
System.out.println("returning value of a");
return a;
}
public static void main(String []args) {
Alfa alfa = new Alfa();
int number = alfa.getAttribute();
System.out.println(number);
}
}
It compiles with javac on both windows (xp) and os x (lion), but it only runs on windows.
This is the command I use to compile the program:
javac -d bin source/edu/oakland/lecture/Alfa.java
This is the command I use to execute it:
java -classpath bin; edu.oakland.lecture.Alfa (I also tried -cp instead of -classpath in Terminal)
As I mentioned, I get the expected output on windows side, but I get this message on the os x side:
-bash: edu.oakland.lecture.Alfa: command not found
I know it has to be something stupid simple; what am I overlooking?
Thanks!
The classpath separator on UNIX-like systems (such as OS X) is ‘:’, not ‘;’. Your command should just be
If you actually did have several different components to your classpath, it would look like: