aspose file tools*
The moose likes Beginning Java and the fly likes javac options Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "javac options" Watch "javac options" New topic
Author

javac options

Guy Rich
Ranch Hand

Joined: May 03, 2011
Posts: 33

Hi all ...I'm compiling a program that has a package statement.
e.g. package APPC_LU62.Runtime ;

I also have a pre-existing directory structure that matches the package statement.
C:\APPC_LU62\Runtime

How do I keep the javac compiler from creating the same directory structure within the pre-existing one ??

i.e. C:\APPC_LU62\Runtime\APPC_LU62\Runtime

It seems to me the compiler ought to be "smart" enough to check first for an existing directory structure before creating one.

Thanks

Guy

Jared Malcolm
Ranch Hand

Joined: May 02, 2011
Posts: 54

Only time that javac creates a directory structure for you is if you pass it the -d flagg (javac -d blah blah).

INSIDE of the dir of the .java file you should run...
javac filename.java

Then to run the program you go to the base dir of the program so in the example you gave that would be c:\

And run...

java APC_LU62.Runtime.ClassName

and java SHOULD do the rest for you


SCJA 6 (Studying for SCJP 6)
Guy Rich
Ranch Hand

Joined: May 03, 2011
Posts: 33

Hi Jared thanks for your response ... I'm not making myself clear however... What I'm talking about is the destination of the class files that are built when the compiler runs. here's my actual options file I pass to the compiler.
-g
-verbose
-deprecation
-implicit:class
-classpath C:\JVM\ibm_sdk60\;C:\JVM\CS_SNA_API_Client\;C:\JVM\CS_SNA_API_Client\CPICJAVA.JAR;C:\JVM\CS_SNA_API_Client\CPICJAVA.DLL
-sourcepath C:\APPC_LU62\Runsrc
-d C:\APPC_LU62\Runtime
-s C:\APPC_LU62\Runsrc

the ouyput og javac -help
Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.

C:\Users\Administrator.DB-SERVER-01>cd \

C:\>cd JVM\ibm_sdk60\bin

C:\JVM\ibm_sdk60\bin>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 and annotation processors
-cp <path> Specify where to find user class files and annotation processors
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-endorseddirs <dirs> Override location of endorsed standards path
-proc:{none,only} Control whether annotation processing and/or compilation is done.
-processor <class1>[,<class2>,<class3>...]Names of the annotation processors to run; bypasses default discovery process
-processorpath <path> Specify where to find annotation processors
-d <directory> Specify where to place generated class files
-s <directory> Specify where to place generated source files
-implicit:{none,class} Specify whether or not to generate class files for implicitly referenced 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
-version Version information
-help Print a synopsis of standard options
-Akey[=value] Options to pass to annotation processors
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system


the -d option tells the compiler where to place the generated class files. However what it actually does is to create a directory structure based on the the
package statement and places the class files in it. Since I already have an existing directory structure that actually matches the package statement I need to know how to "tell" the compiler NOT to create a new directory structure, but rather use the existing one.
Thanks

Guy
Jared Malcolm
Ranch Hand

Joined: May 02, 2011
Posts: 54

That's what I'm saying it does not in any way create a directory for you without the -d......

copy and past the commands your trying to get to work and I can try and help more.
Guy Rich
Ranch Hand

Joined: May 03, 2011
Posts: 33

Hi Jared, thanks very much for your response ... okay I'll accept that IF I don't specify a -d (destination) option now directory will be created.
So now my question becomes where will the compiler place the generated class files ???

I had copied my options file into the last post, but here it is again ...

-g
-verbose
-deprecation
-implicit:class
-classpath C:\JVM\ibm_sdk60\;C:\JVM\CS_SNA_API_Client\;C:\JVM\CS_SNA_API_Client\CPICJAVA.JAR;C:\JVM\CS_SNA_API_Client\CPICJAVA.DLL
-sourcepath C:\APPC_LU62\Runsrc
-d C:\APPC_LU62\Runtime
-s C:\APPC_LU62\Runsrc


Thanks

Guy

Jared Malcolm
Ranch Hand

Joined: May 02, 2011
Posts: 54

if you are using ALL those command you are probably over complicating your compilation of the .class file.......use the two command I gave you above......and use it like I listed above and all should be fine.

Also just out of curiosity are you using command line for a specific purpose like test preparation? If not I'd recommend looking into Netbeans or Eclipse. They handle all of this for you and let you focus more on coding.
Guy Rich
Ranch Hand

Joined: May 03, 2011
Posts: 33

Hi Jared . Yes I am using the command line I really don't feel like using eclipse outside of just editing .. I know it does a lot of things "for you", However
at least for me I find the product somewhat obtuse, and I don't want to spend a lot of time learning how to use it. Besides I want to know what's going on
"behind the scenes".. I tried running my compilation (which does compile cleanly by the way) w/o the -d(estination) parameter.
The compiler then place the generated class files in my source directory.
I can't believe the javac compiler cannot handle the situation of pre-existing directory structures. I've seen (and I'm sure you have too) where installers
will give the user the option of either 1) placing files in a "default" directory, or 2) using a directory you specify, and IF it doesn't exist then creating it.

I've written scripts that have done all three myself...
Anyway thanks very much for your help and suggestions

Guy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javac options