首页 > 解决方案 > 如何在 Windows 上的 Atom 中编译和运行 Java 类?

问题描述

在 Linux 中,很容易在终端中编译和运行 Java 文件:

$ javac App.java
$ java App

有没有办法在 Windows 中专门在 Atom 编辑器中执行此操作?我下载platformio-ide-terminal了包,它打开了一个终端,但是当我运行javac App.java它时,它给了我这个错误:

javac : The term 'javac' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path
is correct and try again.
At line:1 char:1
+ javac App
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (javac:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

如果我可以在没有 IDE 的情况下在 Windows 中运行 java 代码,并且无需在虚拟机或双启动中进入 Linux,那将很有帮助,因为我们必须使用命令行来运行和编译第一学期 CS 课程的 java。

标签: javaatom-editorjavac

解决方案


这不是 Atom 的问题。您的 JDK 安装不正确。JDK 不在 Windows PATH 上,因此无法找到javac.

运行安装程序让它为您修复 PATH,或者手动将 JDK 添加到 PATH中。


推荐阅读