简体   繁体   中英

Refer to classpath within .properties file

Say my classpath is set to C:/long/obscure/path/name , and within name are two directories, foo and bar . I want to pass the location of foo and bar from a .properties file without including the whole path name.

My idea was to try referencing the class path with

fooPath = /foo

or

barPath = %CLASSPATH%/bar

but these do not work.

Is it possible to refer to the classpath within the properties file without explicitly defining it therein?

If you have c:/long/obscure/path/name in the classpath, you only have to refer to /foo

If you want the full classpath:

  1. Get /foo from your properties file
  2. Get the classpath from the system:

    String classPath = prop.getProperty("java.class.path", null);

  3. joint the two strings

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM