轻松的命令行Java编译

轻松的命令行Java编译

本文介绍了轻松的命令行Java编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我必须发送一个java项目给我们公司以外的人没有java经验,他们需要编译它。有没有一个简单的方法来做它在Windows命令行,不需要写出文件列表?

So I have to send a java project to someone outside our company who has no experience with java and they need to compile it. Is there an easy way to do it on the windows command line that does not require writing out lists of the files?

我个人认为javac应该足够聪明地处理

Personally I think javac should be smart enough to handle

javac *

当位于包层次结构根目录下的文件夹中时。在这个球场有什么吗?

when in the folder just under the root of the package hierarchy. Is there anything in this ballpark?

编辑:源文件夹结构是复杂的,没有单一的输入类,所以一些提到的想法到目前为止不工作。谢谢!

The source folder structure is complex and the is no single entry class so some of the ideas mentioned so far won't work. Thanks though! Think 9 levels deep with code on many levels.

推荐答案

从表示包层次结构基础的文件夹中,假设您的输入point类被称为Main,在一个名为app的包中,

From the folder that represents the base of your package hierarchy, assuming your entry point class is called Main, in a package called app,

javac -classpath . app/Main.java

应该生成正确的类定义。编译器将忽略依赖性并编译任何其他需要的类。类文件将出现在与其源文件相同的目录中。

should generate the correct class definitions. The compiler will ferret out the dependencies and compile whatever other classes are needed. The class files will appear in the same directory as their source files.

如果,如你所说,你有多个条目类,最少标识所有来自依赖关系层次结构的顶级类,它们可以作为javac的其他参数列出,指定发生时的包。像这样,假设你还需要从other.Entry开始

If, as you say, you have 'more than one entry' class, you will have to at least identify all those top level classes from the dependency hierarchy, which can be listed as further params to javac, specifying the packages as they occur. Like so, assuming you also need to start with other.Entry

javac -classpath . app/Main.java other/Entry.java

请注意,您仍然必须找出你的类是独立依赖关系层次的顶部,无论你是创建一个ant脚本还是这样做。

Note that you will still have to figure out which of your classes are tops of independent dependency hierarchies, whether you are creating an ant script or doing it this way.

这篇关于轻松的命令行Java编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 05:45