简体   繁体   English

使用netbeans gui编辑器在用NetBeans编写的命令行Java桌面应用程序中进行编译?

[英]Compile in command line java desktop app written in NetBeans with netbeans gui editor?

I made my project in Netbeans but my professor said it must be able to compile it with command line. 我在Netbeans中创建了我的项目,但是我的教授说它必须能够使用命令行进行编译。 So tried everything i still get errors like : org.jdesktop.application package does not exist? 所以尝试了一切,我仍然收到类似org.jdesktop.application包的错误消息?

Please help me how to feed the line in the command prompt. 请帮助我如何在命令提示符下输入该行。

您需要在类路径中有app-framework.jar ,如果从NB运行它,则在类路径中。

Use -classpath key of javac to include the appropriate jar. 使用javac的-classpath键包含适当的jar。

C:\...\ATM\ATM\src\atm>javac
ATMApp.java ATMView.java CheckIDandPIN.java AccountDetailsServices.java -cp appf
ramework-1.03.jar

This works if the appframework.jar is located in one folder with ATMApp.java 如果appframework.jar位于ATMApp.java的一个文件夹中,则此方法有效

C:\...\ATM\ATM\src>java -classpath .;appframework-1.03.jar atm.ATMApp

This launches your application if you copy the jar to src folder. 如果将jar复制到src文件夹,这将启动您的应用程序。

sounds like a misunderstanding. 听起来像是误会。 By default, Netbeans uses ant to build projects. 默认情况下,Netbeans使用ant来构建项目。 Ant is a CLI build tool. Ant 一个CLI生成工具。 So, most any Netbeans project will easily compile and build as a JAR from the CLI. 因此,大多数任何Netbeans项目都可以轻松地从CLI编译和构建为JAR。 Simply run ant -p build.xml from in the project directory. 只需从项目目录中运行ant -p build.xml You should see options to build. 您应该看到构建选项。 As far as I can recall, ant jar will build and distribute most any SE project out of the box. 据我所记得, ant jar将立即构建并分发大多数SE项目。

That's building from the CLI. 这是从CLI构建的。

Probably the instructions were (back in 2010) to use javac directly. 可能的说明是(早在2010年)直接使用javac

As Jigar said, you have a classpath problem. 正如Jigar所说,您遇到了类路径问题。 Your classpath problem is unrelated to building the JAR from the Netbeans GUI or from the CLI. 您的类路径问题与从Netbeans GUI或CLI构建JAR无关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM