I am trying to build a MakeFile for a java client/server programme.
I have a path like this:
Both client and server use Shared package like this:
import Shared.SharedClass;
...
SharedClass mysharedobject = (SharedClass)UnicastRemoteObject.exportObject(anobject, 0);
My makefile is quite simple
all: compile test
compile :
mkdir -p bin
javac -d bin src/**/*.java
test:
java -classpath bin Server.CServer &
java -classpath bin Client.CClient &
but i receive a ClassNotFoundException: Shared.SharedClass when running server.
It works when all java files are in the same package, but i would like to divide it.
Is there a way either to compile all in the same folder or run properly class files in differents folders.
Edit: I have the same error trying to run a built jar
This is not right:
javac -d bin src/**/*.java
make always runs /bin/sh
, and /bin/sh
is a POSIX shell. POSIX does not define "enhanced" globbing like **
to search all subdirectories. If you add this to your recipe:
ls src/**/*.java
you'll see a list of files that are being compiled. If you need to search multiple subdirectories you'll have to use find
, such as:
javac -d bin $$(find src -name \*.java)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.