如何编辑集成开发环境(IDE)的配置以运行Java应用程序?(IntelliJ)

huangapple go评论137阅读模式
英文:

How to edit configurations of IDE to run a java application...? (IntelliJ)

问题

我知道如何从命令行运行我的Java程序。我的Main.java文件路径是:

my_dir/turtlesolution

turtlesolution 目录下有以下文件:

Main.java
Turtle.java
Turtles.java

我在IntelliJ中将turtlesolution目录作为项目打开。然后我通过双击打开了Main.java文件。我想要运行它之前需要进行“编辑配置”。

于是我点击了“编辑配置”。我选择了“JAR 应用程序”,因为这看起来像是正确的选项。这是弹出的配置窗口:

如何编辑集成开发环境(IDE)的配置以运行Java应用程序?(IntelliJ)

“工作目录”我设置为指向turtlesolution。那么“JAR 路径”是什么?我尝试将它设置为turtlesolution,但它仍然为空白。那个“警告,JAR 文件不存在”是什么意思?

我可以通过以下命令在命令行中运行它:

cd turtlesolution
javac Main.java Turtle.java Turtles.java
cd ../
java turtlesolution/Main

显然这很容易弄清楚。我现在在大学最后一年学习计算机科学,显然这很简单,但我却无法弄清楚如何操作,因为它太简单了,无法被教授……

英文:

I know how to run my Java program from the command line. My path to Main.java is:

my_dir/turtlesolution

turtlesolution has the following:

Main.java
Turtle.java
Turtles.java

I opened turtlesolution as the project, using IntelliJ. I then opened (by double clicking) Main.java. I want to run this. I have to edit configurations before I run it, it seems.

So I clicked edit configurations. I clicked JAR application because this looks like the option. This is what comes up:

如何编辑集成开发环境(IDE)的配置以运行Java应用程序?(IntelliJ)

Working directory, I set it to point to turtlesolution. What is Path to JAR? I tried to set it to turtlesolution but it remains blank. What does Warning, jar file doesn't exist mean?

I can run it from the command line by just doing

cd turtlesolution
javac Main.java Turtle.java Turtles.java
cd ../
java turtlesolution/Main

Aapprently it's very easy to figure out. I'm in my final year of learning CS in university and apparently it's simple, but I can't figure out how to do it, and it's too simple to teach ...

答案1

得分: 1

如果项目中没有任何运行配置,运行按钮也会被禁用。
如果您在具有main方法的文件中右键单击,运行配置将被自动创建,并且主类值将被预填充。对我来说,这对于更多的访问https://intellij-support.jetbrains.com/hc/en-us/community/posts/206811415-Problem-with-Edit-Configurations-有效。

英文:

If you don't have any run configuration in the project, Run button is also disabled.
If you right click in a file with main method, run configuration is created automatically and main class value if prefilled. This worked for me for more vist https://intellij-support.jetbrains.com/hc/en-us/community/posts/206811415-Problem-with-Edit-Configurations-

huangapple
  • 本文由 发表于 2020年3月4日 06:21:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/60516378.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定