how to set classpath for external properties file outside of the single jar?

304 views
Skip to first unread message

Ted Tanaka

unread,
Jun 25, 2013, 11:12:10 PM6/25/13
to one...@googlegroups.com
Hey guys -

Can you tell me how I can set the classpath to pick up a properties file that is outside the big jar?  Using "java -cp /dir -jar one.jar" doesn't seem to work.

I know you have a custom classloader, and wondering if you take into account the externally-defined classpath.

Or can I define the classpath in the maven pom.xml file?

Thanks!

Ted

Simon Tuffs

unread,
Jun 26, 2013, 11:10:51 AM6/26/13
to one...@googlegroups.com
Hi Ted:

one-jar supports extending the classpath using a system property.  The property name is one-jar.class.path (http://one-jar.sourceforge.net/index.php?page=details&file=options), and can be specified on the command line (see documentation), or baked into the jar.

You can bake this into your one-jar by including a one-jar.properties file in the top-level of your jar.  This file is read and the properties are asserted before the JarClassLoader is created.  The JarClassLoader uses one-jar.class.path to augment its search list during its init() method.  Multiple elements on the one-jar.class.path are separated by '|'.

Let me know if this works for you.

Simon.
Reply all
Reply to author
Forward
0 new messages