我在 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 中运行该程序,似乎没问题。它只是抱怨没有参数,正如我所料)
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
如果它真的有助于解决问题,我可以包含代码和输出,但如果它只是一个编译问题,我不想让这个问题变得巨大。有没有人有什么建议?