yairabr yairabr - 2 years ago 85
Linux Question

Compiling java source code on linux

I'm trying to compile my source code which divided into different packages.
i wrote a sources text and list inside it all the paths of the java files.
i also made a makefile and wrote the following lines:

compile: bin
javac -d bin -cp biuoop-1.4.jar @sources.txt
java -cp biuoop-1.4.jar:bin Ass5Game 2 4
mkdir bin

the biupoop is a built jar file i'm using.

after i use the make commend the computer says:

javac -d bin -cp biuoop-1.4.jar @sources.txt
javac: file not found: animations\Animation.java
Usage: javac <options> <source files>
use -help for a list of possible options
make: *** [compile] Error 2.

how do i compile the files in packages?

Answer Source

The key is in this error message:

javac: file not found: animations\Animation.java

Note the backslash. On *nix, paths are separated with slash (/), not backslash (\). If you change the \ in your sources.txt to / instead, it will work (assuming you're running this in the directory that animation is a subdirectory of).

Example run:

$ cat animation/Animation.java 
package animation;

public class Animation {
    public static final void main(String[] args) {
$ cat sources.txt 
$ javac -d bin @sources.txt
$ java -cp bin animation.Animation
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download