2011-06-28 24 views
0

我想使用BAT文件將java.library.path設置爲當前目錄。在Windows 7上使用BAT文件設置java.library.path

繼承人我用:

java -Djava.library.path=%cd% 
pause 

但是它不工作。命令promt只是返回這個:

C:\Users\Johan-bar\Desktop\Arbete>java -Djava.library.path=C:\Users\Johan-bar\De 
sktop\Arbete 
Usage: java [-options] class [args...] 
      (to execute a class) 
    or java [-options] -jar jarfile [args...] 
      (to execute a jar file) 

where options include: 
    -client  to select the "client" VM 
    -server  to select the "server" VM 
    -hotspot  is a synonym for the "client" VM [deprecated] 
        The default VM is client. 

    -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. 
    -D<name>=<value> 
        set a system property 
    -verbose[:class|gc|jni] 
        enable verbose output 
    -version  print product version and exit 
    -version:<value> 
        require the specified version to run 
    -showversion print product version and continue 
    -jre-restrict-search | -jre-no-restrict-search 
        include/exclude user private JREs in the version search 
    -? -help  print this help message 
    -X   print help on non-standard options 
    -ea[:<packagename>...|:<classname>] 
    -enableassertions[:<packagename>...|:<classname>] 
        enable assertions 
    -da[:<packagename>...|:<classname>] 
    -disableassertions[:<packagename>...|:<classname>] 
        disable assertions 
    -esa | -enablesystemassertions 
        enable system assertions 
    -dsa | -disablesystemassertions 
        disable system assertions 
    -agentlib:<libname>[=<options>] 
        load native agent library <libname>, e.g. -agentlib:hprof 
        see also, -agentlib:jdwp=help and -agentlib:hprof=help 
    -agentpath:<pathname>[=<options>] 
        load native agent library by full pathname 
    -javaagent:<jarpath>[=<options>] 
        load Java programming language agent, see java.lang.instrument 

    -splash:<imagepath> 
        show splash screen with specified image 

C:\Users\Johan-bar\Desktop\Arbete>pause 

我做了什麼錯了?

+0

錯誤信息是否清除?您缺少java命令的必需參數。 – KDM

+0

我不明白缺失的是什麼 – KaiserJohaan

+0

您錯過了前四行錯誤中指出的classname或'jar jarfile'。 – wjans

回答

1

你的命令沒有很好形成,由錯誤消息指出。既然你正在嘗試運行一個jar文件,你應該像這樣指定它:

java [-options] -jar jarfile [args...] 

在你的情況,這將是:

java -Djava.library.path=%cd% -jar myJar 

注:爲jar參考應包含擴展以及。如果您的罐子實際上被稱爲myJar,請考慮將其更改爲具有.jar擴展名。如果不是,則將.jar添加到上述命令。

+0

我不想運行jar文件。我只是想將文件夾添加到java.library.path中,因爲稍後我將運行一個將加載庫的小程序。 – KaiserJohaan

+0

你應該在你的問題中提到過這一點,它完全改變了情況。你的問題是如何在運行applet時指定'java.library.path'。使用指定的屬性啓動Java進程只會使該屬性知道您啓動的進程。我不知道如何爲applet做這件事。 – wjans

+0

我需要再次澄清一下:首先運行一個批處理文件,然後運行加載applet的html文件。所以它不在運行時;它在你運行applet之前:p – KaiserJohaan

0

你可能已經忘記了引號"

試試這個:

java "-Djava.library.path=C:\Users\Johan-bar\Desktop\Arbete" 
+0

另外,不要爲了得到正在運行的實際命令。 ;-) – cjstehno

+0

它沒有工作 – KaiserJohaan

+0

然後問題是別的 –