470,874 Members | 1,457 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,874 developers. It's quick & easy.

Compiling -- Can I Control Where .java and .class Files Are Kept?

My first Java project has gotten to the point where there are so many .java
and .class files that I'd like to keep them separated so I can easily keep
files straight. I have my /home/me directory and I want to put my .java
files in /home/me/src and my class files in /home/me/bin. For now, I'm
keeping the .java files in /home/me/src and, after I compile a class, I do
"mv src/*class bin/" to transfer the newly generated .class files into the
bin directory.

Is there any way to tell javac that all .class files should be put in the
bin dir? I can deal with adding "src/" onto my javac commands, although it
would nice to have javac look in a "default" directory for .java files
first, but I'd really like to have the .class files moved over
automatically (it is also a problem when I'm compiling more than one class
at a time when the second class uses new methods in the first class).

Thanks!

Hal
Jul 17 '05 #1
3 3076
Hal Vaughan wrote:
Is there any way to tell javac that all .class files should be put in the
bin dir?


Use the -d switch

$ javac -help
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs
are used
-classpath <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified
release
-target <release> Generate class files for specific VM version
-help Print a synopsis of standard options

--
Jonas Kongslund
Jul 17 '05 #2
Jonas Kongslund wrote:
Hal Vaughan wrote:
Is there any way to tell javac that all .class files should be put in the
bin dir?


Use the -d switch

$ javac -help
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is
doing
-deprecation Output source locations where deprecated APIs
are used
-classpath <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source
files
-source <release> Provide source compatibility with specified
release
-target <release> Generate class files for specific VM version
-help Print a synopsis of standard options


Thought I did that, but when I tried it, I realized that I had read the help
for java, not javac. Thanks.

Hal
Jul 17 '05 #3
Get yourself a good easy to use Java IDE like JCreator LE (which is free!)
and let the IDE manage all these things. Download at:
http://www.jcreator.com/

Larry

"Hal Vaughan" <ha*@thresholddigital.com> wrote in message
news:ZYCwb.225814$275.860373@attbi_s53...
My first Java project has gotten to the point where there are so many ..java and .class files that I'd like to keep them separated so I can easily keep
files straight. I have my /home/me directory and I want to put my .java
files in /home/me/src and my class files in /home/me/bin. For now, I'm
keeping the .java files in /home/me/src and, after I compile a class, I do
"mv src/*class bin/" to transfer the newly generated .class files into the
bin directory.

Is there any way to tell javac that all .class files should be put in the
bin dir? I can deal with adding "src/" onto my javac commands, although it would nice to have javac look in a "default" directory for .java files
first, but I'd really like to have the .class files moved over
automatically (it is also a problem when I'm compiling more than one class
at a time when the second class uses new methods in the first class).

Thanks!

Hal

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Herman | last post: by
3 posts views Thread by Isa | last post: by
29 posts views Thread by Maurice LING | last post: by
1 post views Thread by C Downey | last post: by
7 posts views Thread by maya | last post: by
4 posts views Thread by betalpha | last post: by
4 posts views Thread by anon538 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.