无法将class编译成jar文件?

问题描述 投票:0回答:1

我是 Java 的新手,我想弄清楚如何将我的 Java 代码编译成 jar 文件。我已经想出如何将我的文件编译成一个类文件,但是当我尝试运行编译命令时它给了我这个错误。

jar : The term 'jar' 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
jar cvf Test.jar *
+ ~~~
CategoryInfo          : ObjectNotFound: (jar:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException

我使用的教程告诉我在终端中运行这个命令。

jar cvf Count.jar Count.class

然而,这一切只是抛出上述错误。同样,我是 Java 的新手,所以也许我遗漏了一些东西。

java jar compilation
1个回答
0
投票

感谢@Strom 的回答。我在 Visual Studio Code 的终端而不是 CMD 中使用命令。

© www.soinside.com 2019 - 2024. All rights reserved.