I was working on the Java program that used a 3rd party jar from Bouncy Castle. Although I was pretty sure the jar was included during the compilation, the cannot find symbol error was spit out.
javac -cp:./bcxxxxxx.jar MyProgram.java
After a while of confusion and frustration, I finally found out that there was another older version of the same Bouncy Castle jar lying on Java's extension directory. The compiler loaded the same class from the old jar first and ignored the duplicate one loaded later from the bcxxxxxx.jar that I tried to use. Unfortunately, the old one did not contain the method I was trying to use.
To solve this problem, I wanted javac to use my downloaded bcxxxxxx.jar and ignore the on the system's path. The compile option -Xbootclasspath/p:path came in handy:
-Xbootclasspath/p:path
Prepend to the bootstrap class path.
To compile it:
javac -Xbootclasspath/p:./bcxxxxxx.jar MyProgram.java
To run it:
java -Xbootclasspath/p:./bcxxxxxx.jar MyProgram
Friday, February 3, 2017
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment