0

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
run:
    java -cp biuoop-1.4.jar:bin Ass5Game 2 4
bin:
    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?

8
  • 1
    What is the current directory you issue the call from and where are the sources relative to that location? Commented May 24, 2016 at 9:15
  • Why are you using makefiles for java? It works I guess but there are build tools such as maven and gradle (more github.com/tkruse/build-bench ) that make building java projects far simpler. Commented May 24, 2016 at 9:18
  • i'm in the user directory, and i have a "src" file which inside it there are couple of packages. for example one of the paths is "animations\Animation.java". Commented May 24, 2016 at 9:20
  • That \ seems a little strange to me as on Linux the path separator is /. Commented May 24, 2016 at 9:21
  • @zapl, i need to as part of my assignment. Commented May 24, 2016 at 9:22

1 Answer 1

5

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) {
        System.out.println("Success");
    }
}
$ cat sources.txt 
animation/Animation.java
$ javac -d bin @sources.txt
$ java -cp bin animation.Animation
Success
Sign up to request clarification or add additional context in comments.

2 Comments

the problem was that i needed to add the following line:find src -name "*.java" > sources.txt on the makfile
@yairabr: Yup. That will, indirectly, do what I said above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.