在命令行上编译netbeans程序

时间:2012-11-08 18:11:29

标签: java netbeans command-line import compiler-errors

我在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

我可以包含代码和输出,如果它真的有助于解决问题,但我不想让问题变得很大,如果它只是一个编译问题。 有没有人有什么建议?

1 个答案:

答案 0 :(得分:0)

我最终只使用netbeans来修复命令行运行。我确保我的程序被设置为主程序然后我使用了小“干净和构建”锤子,我的所有问题都消失了。 <{1}}之后工作得很好