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 will gain a lot of times by installing Eclipse and configure the folder which contains the classes as an Eclipse project (using the Import feature).
It will avoid you to pass as arguments the required JAR libraries, the output folder,...
I would need to see a file listing to be sure but it sound like it should be in colourtiler/patterns.
Use the -classpath (aka -cp) or -sourcepath arguments to set base source locations. Use the -classpath argument to specify binary dependencies (jar files or base .class file directories). Use the -d argument to specify the output directory.
One thing to watch out for is that namespaces (packages) must match directory structures.
A class file declaring
package foo;
must be in the directoryfoo
. A class file declaringpackage foo.foo;
must be in the directoryfoo\foo
and so on.See the documentation for javac. See here for more extensive
classpath
documentation.You first need to compile
patters/PatternColour.java
and then add the resultant classes' location to your classpath when compilingMain.java
You need to include its path in the javac/java's
-cp
or-classpath
argument. E.g.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.