File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes compiling packages with javac using appropriate directory structure Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "compiling packages with javac using appropriate directory structure" Watch "compiling packages with javac using appropriate directory structure" New topic
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compiling packages with javac using appropriate directory structure
 
Similar Threads
<indentifier> expected
Related to Javac Command
error javac + javaee.jar : custom classpath
Problem using javac: cannot find symbol(method)
Can Import create a directory "planets"