Setting classpath with benchmark.java

Alan Burlison Alan.Burlison at oracle.com
Wed Sep 12 16:48:57 UTC 2018


I'm trying to run a benchmark which needs a specific classpath setting, 
to include a library that isn't available via Maven.

Unfortunately it seems to be impossible to set the classpath with jmh. 
I'm using "-jvmArgs '-Djava.class.path=/opt/instantclient/ojdbc8.jar" to 
try to do so but here's the resulting command-line that's used to run 
the target VM by benchmark.java:

Forking 10 times using command: 
[/usr/lib/jvm/oracle-java8-jdk-amd64/jre/bin/java, -cp, 
/opt/instantclient/ojdbc8.jar, -Djava.library.path=/opt/instantclient, 
-Dargs.mode=thin, 
-XX:CompileCommandFile=/tmp/jmh8572122209057614698compilecommand, -cp, 
target/benchmarks.jar, org.openjdk.jmh.runner.ForkedMain, 127.0.0.1, 43795]

Because benchmark.java is appending "-cp target/benchmarks.jar" the 
second "-cp" wins and overrides the one specified with "-jvmArgs". I 
can't imagine I'm the first person to have needed to set the classpath 
for a jmh benchmark but I haven't been able to find any way around the 
problem, and it is a showstopper for me.

Thanks,

-- 
Alan Burlison
--


More information about the jmh-dev mailing list