简体   繁体   English

如何从命令行编译/运行netbeans项目?

[英]how to compile/run a netbeans project from command line?

I have this netbeans project structure: 我有这个netbeans项目结构:

/my_project
|__/controllers
|   |__/factories
|      |__Factory.java
|   |__/integrator
|      |__Integrator.java
|
|__/models
|   |_Models.java
|
|__/main
    |_Main.java   

But, how can I compile/run it from command line? 但是,如何从命令行编译/运行它?

This post works for me to compile, but not for run it. 这篇文章适合我编译,但不适合运行它。

There is a way to run it without using tools like Ant? 有一种方法可以在不使用Ant等工具的情况下运行它吗?

If you do not use any external jar you can easily write an OS script (sh or bat) which calls javac for all those .java files and then (another one which) calls java on the .class file containg the void main(String[] args) method and sets the classpath. 如果您不使用任何外部jar,您可以轻松编写一个OS脚本(sh或bat),它为所有这些.java文件调用javac ,然后(另一个)在包含void main(String[] args).class文件上调用java void main(String[] args)方法并设置类路径。

If you want to use other libraries (provided in jar files) and you want to keep your script the same; 如果你想使用其他库(在jar文件中提供)并且你想保持你的脚本相同; you can copy them at this location: JAVA_HOME/lib/ext, where JAVA_HOME is the environment variable pointing to where the JVM (jre) is installed 你可以在这个位置复制它们:JAVA_HOME / lib / ext,其中JAVA_HOME是指向JVM(jre)安装位置的环境变量

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

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