Can I find out what variable java.library.path maps to on the current platform?

前端 未结 2 641
忘掉有多难
忘掉有多难 2020-12-15 04:12

So far I\'ve learned the following about the java.library.path property:

  • It\'s used when loading native libraries, as opposed to java classes
  • Its defa
2条回答
  •  情书的邮戳
    2020-12-15 04:21

    On my linux box, here is what I would do:

    $ cat GetSystemProperty.java
    import java.util.Properties;
    import java.util.Enumeration;
    
    public class GetSystemProperty {
      public static void main(String args[]) {
        if( args.length == 0 ) {
          Properties p = System.getProperties();
          Enumeration keys = p.keys();
          while (keys.hasMoreElements()) {
            String key = (String)keys.nextElement();
            String value = (String)p.get(key);
            System.out.println(key + " : " + value);
          }
        }
        else {
          for (String key: args) {
            System.out.println(System.getProperty( key ));
          }
        }
      }
    }
    $ javac GetSystemProperty.java
    $ java GetSystemProperty java.library.path
    /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib
    

提交回复
热议问题