Websphere Liberty 8.5: Setting Java classpath

2020-03-07 06:50发布

I am running Websphere Liberty 8.5. My application reads some files from the file system that are obtained via the Java CLASSPATH and I can't seem to find a way to append a directory from the file system to the CLASSPATH Liberty reads from. I've tried manually changing JAVA_CMD and JAVA_DEBUG but none of them take.

Does anyone know how this is possible?

2条回答
戒情不戒烟
2楼-- · 2020-03-07 07:08

It is not possible to modify the JVM application classpath (normally specified via the -classpath JVM argument or the CLASSPATH environment variable). I would recommend using a <library> to give your applications visibility to the resources. If you need a directory, you should use <library><folder dir="..."/></library>.

(As an aside, modifying the wlp/bin scripts or setting those "internal" script variables is not a supported external.)

查看更多
相关推荐>>
3楼-- · 2020-03-07 07:13

ANOTHER WARNING! It only reads JAR files! I had the same issue with endless frustration. Even if you use the <library><folder dir="..."/></library> method above, it will only read jar files from the classpath. I had a bunch of properties files that I read from the classpath in JBOSS, WebSphere (full), and Glassfish, but the same method doesn't work for Websphere Liberty. What I ended up doing is the above, and putting my properties files all in a .jar file. Very annoying but a work-around, in case you need to read non-jar files.

查看更多
登录 后发表回答