How to add deploy.jar to classpath?
Posted
by dma_k
on Stack Overflow
See other posts from Stack Overflow
or by dma_k
Published on 2010-03-24T17:45:04Z
Indexed on
2010/03/28
7:33 UTC
Read the original article
Hit count: 264
java
|classloader
I am facing the problem: I need to add ${java.home}/lib/deploy.jar
JAR file to classpath in the runtime (dynamically from java).
- The solution with
Thread#setContextClassLoader(ClassLoader)
(mentioned here) does not work because of this bug (if somebody can explain what is really a problem – you are welcome). - The solution with
-Xbootclasspath/a:"%JAVA_HOME%/jre/lib/deploy.jar"
does not work well for me, because I want to have "pure executable jar" as a deliverable: no wrapping scripts please (more over%JAVA_HOME%
may not be defined in user's environment in Windows for example, plus I need to write a script per platform) - The solution with merging
deploy.jar
file into my deliverable works only if I make a build on Windows platform. Unfortunately, when the deliverable is produced on build server running on Linux, I got Linux-dependant JAR, which does not execute on Windows – it fails with the trace below.
I have read How the Java Launcher Finds Classes and Java programming dynamics: Java classes and class loading articles but I've got no extra ideas, how to correctly handle this situation.
Any advices or solutions are very welcomed.
Trace:
java.lang.NoClassDefFoundError: Could not initialize class com.sun.deploy.config.Config
at com.sun.deploy.net.proxy.UserDefinedProxyConfig.getBrowserProxyInfo(UserDefinedProxyConfig.java:43)
at com.sun.deploy.net.proxy.DynamicProxyManager.reset(DynamicProxyManager.java:235)
at com.sun.deploy.net.proxy.DeployProxySelector.reset(DeployProxySelector.java:59)
...
java.lang.NullPointerException
at com.sun.deploy.net.proxy.DynamicProxyManager.getProxyList(DynamicProxyManager.java:63)
at com.sun.deploy.net.proxy.DeployProxySelector.select(DeployProxySelector.java:166)
© Stack Overflow or respective owner