开发者

What will netbeans IDE do when I press Ctrl+F6 to run a java file?

I have no idea of how Netbeans IDE run a java file.

Firstly, it would ensure the .class file is up-to-date.

Then, execute the class. But from where (working directory) and with which command (parameter)?

I o开发者_运维知识库bserve difference on how relative path is located when I run the java file from Netbeans IDE and when I run using Windows command prompt (i.e > java pack.age.name.ClassName)


You can find that out by putting this at the start of the main method of the class:

System.out.println(new File(".").getAbsolutePath());

It looks like it will run from the directory that the project is in (eg. ....\NetBeansProjects\JavaApplication1)

You cannot specify command line arguments for a single class (that I am aware of). To do that you have to use the Project | Properties (and there you can also set the working directory).

I would suggest that you do not write code that depends on the working directory if you can avoid it though...


You can get informative results by running the project's build.xml from the command line in verbose mode: ant -verbose run. Look for the [java] command options under run:. Typing ant -p will show you the available targets.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜