我在 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
如果代码和输出确实有助于解决问题,我可以包含它,但如果这只是一个编译问题,我不想让问题变得很大。 有没有人有什么建议?
最佳答案
我最终只是使用 netbeans 来修复命令行运行。我确保我的程序被设置为主程序,然后我使用小“清理和构建”锤子,我所有的问题都消失了。 java -jar /home/Stephanie/NetBeansProjects/consistentBelow/dist/consistentBelow.jar -o /home/Stephanie/out9.txt -f /home/Stephanie/ -c /home/Stephanie/Data/48cov1.txt -l /home/Stephanie/Data/list.txt 48e.doc 48.doc
之后工作得很好
关于java - 在命令行上编译 netbeans 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13295132/