Reputation: 1869
I try to add -bootclasspath option when compiling java source like this:
javac -classpath lib/* -target 1.6 -source 1.6 -bootclasspath /usr/lib/jvm/java-7-oracle/lib/*.jar Hello.java
I am getting the following error when compiling:
javac: invalid flag: /usr/lib/jvm/java-7-oracle/lib/dt.jar
Usage: javac <options> <source files>
use -help for a list of possible options
How should I add the bootclasspath parameter?
Upvotes: 2
Views: 19438
Reputation: 311
Try something like this:
java -bootclasspath $(set -- /usr/lib/jvm/java-7-oracle/lib/*.jar ; IFS=:; echo "$*")
Be running bash when you try it, the bourne again shell is the bee's knees.
Upvotes: 0
Reputation: 3186
The shell expands /usr/lib/jvm/java-7-oracle/lib/*.jar to the list of jars, so effectively javac is called like that:
javac ... -bootclasspath /usr/lib/jvm/java-7-oracle/lib/rt.jar /usr/lib/jvm/java-7-oracle/lib/dt.jar ... Hello.java
You can avoid that by putting the path between single quotes:
javac ... -bootclasspath '/usr/lib/jvm/java-7-oracle/lib/*.jar' ... Hello.java
Upvotes: 10
Reputation: 1869
I added this -bootclasspath /usr/lib/jvm/java-7-oracle/jre/lib/rt.jar instad of /usr/lib/jvm/java-7-oracle/lib/*.jar and it worked fine.
Upvotes: 3