如何编译java代码? [英] How to compile java code?
问题描述
我有一堆java文件,我正在运行以下代码来尝试编译它们。 \\Program Files\Java\jdk1.6.0_16\bin\javacMain.java
我正在看到此错误消息
Main.java:3:package colourtiler.patternsdoes不存在
import colourtiler.patterns.draw;
它所代表的代码位于文件夹patters / PatternColour.java中,包含此文件?
感谢
它在javac / java的 -cp
或 -classpath
参数中的路径。例如
javac -cp。; c:/ path / to / colourtiler / patterns / draw Main.java
其中 c:/ path / to / colourtiler / patterns / draw
指向依赖关系类的包根。如果你有更多,那么你需要用分号分隔它。如果路径中有空格,则需要引用单个路径。或者,您也可以将它包装在JAR文件中(或使用已打包的文件),并将完整的文件路径放在类路径中的JAR文件中。
输入类路径会感到无聊,请考虑使用批处理/ shell文件。
祝你好运。
I have a bunch of java files and I am running the following code in an attempt to compile them.
"\Program Files\Java\jdk1.6.0_16\bin\javac" Main.java
And I am being shown this error message
Main.java:3: package colourtiler.patternsdoes not exist
import colourtiler.patterns.draw;
The code it isreferring to is located in the folder patters/PatternColour.java, how can I get it to include this file?
thanks
You need to include its path in the javac/java's -cp
or -classpath
argument. E.g.
javac -cp .;c:/path/to/colourtiler/patterns/draw Main.java
where c:/path/to/colourtiler/patterns/draw
points to the package root of the dependency classes. If you have more, then you need to separate it by semicolon. If there are spaces in path, you need to quote the individual path. Alternatively you can also package it in a JAR file (or use an already packed one) and put the full file path to the JAR file in the classpath.
If gathering and typing the classpath get bored, consider using a batch/shell file.
Good luck.
这篇关于如何编译java代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!