简体   繁体   English

从命令行运行在intellij中创建的Java程序

[英]run java program created in intellij from command line

I have a simple Java Maven program that I created in Intellij. 我有一个在Intellij中创建的简单Java Maven程序。 It has Two classes Main and Read . 它有两个类MainRead I was able to build a jar and run it. 我能够建立一个罐子并运行它。 However if I zip the source code into a folder , would I be able to compile it using command line? 但是,如果我将源代码压缩到一个文件夹中,是否可以使用命令行对其进行编译? Something like javac ? javac一样? How should I do this? 我应该怎么做? Shall I run commands in Java folder in the project? 我可以在项目的Java文件夹中运行命令吗? Many thanks. 非常感谢。

As far as the Java class loader is concerned, a .jar or .zip file is the same as a directory containing the the files, and .jar and .zip files are generally used to distribute compiled Java packages. 就Java类加载器而言,.jar或.zip文件与包含这些文件的目录相同,并且.jar和.zip文件通常用于分发已编译的Java软件包。 Here you can read more about it. 在这里您可以阅读更多有关它的信息。

For compiling the zip file: use the -classpath option to javac and java. 要编译zip文件:对javac和java使用-classpath选项。 We could, for example: 例如,我们可以:

javac -classpath .:/users/johnr/java:/opt/jdk1.1.6/lib/classes.zip Hello.java

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

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