| Author |
compiling packages with javac using appropriate directory structure
|
Rob Sweeny
Greenhorn
Joined: Jan 14, 2010
Posts: 16
|
|
Hi All,
I am trying to set up a meaningful directury structure to house my source and class files
and finally use javac to compile my .java files into class files.
As a noob I'm having problems doing so.
javac can't find my main class GreetingsUniverse.java
This is what I have so far:
C:\java\classes\com\scjaexam\tutorial\planets
C:\java\src\com\scjaexam\tutorial\planets
C:\java\src\com\scjaexam\tutorial\GreetingsUniverse.java
C:\java\src\com\scjaexam\tutorial\planets\Earth.java
c:\java>javac -classpath classes -sourcepath src GrettingsUniverse.java
javac: file not found: GrettingsUniverse.java
c:\java>javac -classpath classes -sourcepath c:\src GrettingsUniverse.java
javac: file not found: GrettingsUniverse.java
c:\java>javac -classpath classes -sourcepath "c:\src" GrettingsUniverse.java
javac: file not found: GrettingsUniverse.java
c:\java>javac -classpath classes -sourcepath "C:\java\src\com\scjaexam\tutorial" GrettingsUniverse.java
javac: file not found: GrettingsUniverse.java
I was able to compile and interpret the code successfully when all files where in the same dir without using the package or imports statements.
|
 |
Matt Jarchow
Greenhorn
Joined: Jan 15, 2010
Posts: 1
|
|
The command you are looking for is:
javac -classpath classes -sourcepath src -d classes src\com\scjaexam\tutorial\GreetingsUniverse.java
You need to specify the full path of the file being compiled.
The -d argument is necessary for the compiler to know where to place your class files. If you leave that out, your .class files will be placed in the "src" heirarchy.
|
 |
 |
|
|
subject: compiling packages with javac using appropriate directory structure
|
|
|