码迷,mamicode.com
首页 > 编程语言 > 详细

java程序 启动时参数

时间:2014-07-19 22:31:36      阅读:747      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   java   color   使用   

 
bubuko.com,布布扣
iEMP34:/opt/version/lktest/b030/jre/jre_linux/bin # ./java -classpath .  SysInfo
Exception in thread "main" java.lang.NoClassDefFoundError: org/hyperic/sigar/SigarException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.getMethod0(Unknown Source)
    at java.lang.Class.getMethod(Unknown Source)
    at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.hyperic.sigar.SigarException
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 6 more
iEMP34:/opt/version/lktest/b030/jre/jre_linux/bin # ./java -classpath  "."  SysInfo
Exception in thread "main" java.lang.NoClassDefFoundError: org/hyperic/sigar/SigarException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.getMethod0(Unknown Source)
    at java.lang.Class.getMethod(Unknown Source)
    at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.hyperic.sigar.SigarException
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 6 more
iEMP34:/opt/version/lktest/b030/jre/jre_linux/bin # ./java -classpath  /opt/version/lktest/b030/jre/jre_linux/bin:.  SysInfo
Exception in thread "main" java.lang.NoClassDefFoundError: org/hyperic/sigar/SigarException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.getMethod0(Unknown Source)
    at java.lang.Class.getMethod(Unknown Source)
    at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.hyperic.sigar.SigarException
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 6 more
iEMP34:/opt/version/lktest/b030/jre/jre_linux/bin # ./java -classpath  /opt/version/lktest/b030/jre/jre_linux/bin/sigar.jar:.  SysInfo
no libsigar-amd64-linux.so in java.library.path
org.hyperic.sigar.SigarException: no libsigar-amd64-linux.so in java.library.path
    at org.hyperic.sigar.Sigar.loadLibrary(Sigar.java:172)
    at org.hyperic.sigar.Sigar.<clinit>(Sigar.java:100)
    at SysInfo.getCpuCount(SysInfo.java:39)
    at SysInfo.main(SysInfo.java:25)
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.hyperic.sigar.Sigar.getCpuInfoList()[Lorg/hyperic/sigar/CpuInfo;
    at org.hyperic.sigar.Sigar.getCpuInfoList(Native Method)
    at SysInfo.getCpuCount(SysInfo.java:41)
    at SysInfo.main(SysInfo.java:25)
You have new mail in /var/mail/root
View Code

 

必须指定具体jar才行吗?

同时注意-cp 和 classpath  是一个意思

-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.

 

这样都不行吗:-classpath /opt/version/lktest/b030/jre/jre_linux/bin/ 

———— 看来就是必须指定具体jar,而不能是目录!

 

-D<name>=<value> ----- 这就是相当于设置了system参数,之后可以使用System.getProperty(name)来获取。
set a system property

java程序 启动时参数,布布扣,bubuko.com

java程序 启动时参数

标签:style   blog   http   java   color   使用   

原文地址:http://www.cnblogs.com/FlyAway2013/p/3663756.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!