By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,541 Members | 1,106 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,541 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.