我在Netbeans中編寫了一個供自己使用的程序,但現在有人想從命令行遠程使用它並給出命令行參數。我改變了代碼接受命令行參數,但我似乎無法讓代碼正常運行。如果我鍵入此(所有必需的命令行參數):編譯命令行上的netbeans程序
java -jar /home/Stephanie/NetBeansProjects/consistentBelow/dist/consistentBelow.jar
-o /home/Stephanie/Data/out9.txt //where the output file should be
-f /home/Stephanie/Data/ //what folder the files are located in
-c /home/Stephanie/Data/48E_cov1.txt //file
-l /home/Stephanie/Data/list.txt //file
48.doc //sample
48e.doc //sample
它運行得很好,但從來沒有產生輸出文件。我試着在命令行重新編譯(思維,也許它運行的是較舊的編譯版本),但它不能識別包之一,我下載到使命令行參數:
javac /home/Stephanie/NetBeansProjects/consistentBelow/src/consistentbelow/ConsistentBelow.java
/home/Stephanie/NetBeansProjects/consistentBelow/src/consistentbelow/ConsistentBelow.java:9: package com.martiansoftware.jsap does not exist
import com.martiansoftware.jsap.*;
^
我想招惹與類路徑周圍,但我似乎無法取得任何進展。
javac -jar /home/Stephanie/NetBeansProjects/consistentBelow/src/consistentbelow/ConsistentBelow.jar -classpath /home/Stephanie/Downloads/JSAP-2.1.jar
Unable to access jarfile /home/Stephanie/NetBeansProjects/consistentBelow/src/consistentbelow/ConsistentBelow.jar
(另外,如果我嘗試運行NetBeans中的程序,現在看來似乎是確定它只是grumps關於不具有參數,如我所料)
Error: Parameter 'out' is required.
Error: Parameter 'folder' is required.
Error: Parameter 'coverage' is required.
Error: Parameter 'list' is required.
Error: Parameter 'samplefile' is required.
Usage: java consistentbelow.ConsistentBelow
(-o|--outputlocation) <out> (-f|--folder) <folder> (-c|--coverage) <coverage> (-l|--list) <list> samplefile1 samplefile2 ... samplefileN
(-o|--outputlocation) <out>
Where would you like the resulting file to be put? Full path and desired
file name
(-f|--folder) <folder>
What folder will we find the sample files in? Full path
(-c|--coverage) <coverage>
Where is the coverage file? Full path
(-l|--list) <list>
Where is the interval list file? Full path
samplefile1 samplefile2 ... samplefileN
Please write the full file name for each sample we will look at
Java Result: 1
如果能真正幫助解決問題,我可以包含代碼和輸出,但如果僅僅是編譯問題,我不想讓這個問題變得很大。 有沒有人有任何建議?
你能解釋一下嗎?我不確定如何: - 確保螞蟻在路徑中 - 確保JAVA_HOME設置正確 - 在netbeans項目的目錄中執行「ant clean」和「ant jar」 – Stephopolis