• Post Reply Bookmark Topic Watch Topic
  • New Topic

about javac option -d.  RSS feed

 
s sivaraman
Ranch Hand
Posts: 59
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
while compiling the java program in a package, i want to store the class file in to the file directory as the package name.
i know i can use -d option. but my doubt is that if i should manually create the directory or the javac -d command takes care of it.

thank you
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s sivaraman wrote:i know i can use -d option. but my doubt is that if i should manually create the directory or the javac -d command takes care of it.
Hi,

What have you discovered when you tried that?
 
s sivaraman
Ranch Hand
Posts: 59
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:

What have you discovered when you tried that?


thank you for your response.

i've a Fruit.java(D:\J\excercise) class in the package Food.

After i manually created Food folder in D:\J\excercise
i compiled using
D:\J\excercise> javac -d Food Fruit.java

it forms the .class file directory as D:\J\excercise\Food\Food\Fruit.class.

then i tried this,
i removed the Food from this D:\J\excercise\Food\
then i compiled like before, i got this
javac: file not found: Fruit.java
Usage: javac <options> <source files>
use -help for a list of possible options
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Remove "Food" folder.
2. Be in that location "D:\J\excercise"
3. Execute "javac -d . Fruit.java"

See what happens then. Try to figure out, what "." means.
 
s sivaraman
Ranch Hand
Posts: 59
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Execute "javac -d . Fruit.java"

that works man..thank you...

See what happens then. Try to figure out, what "." means.

i figured it commands the system to create a folder as the package in the current working directory
and i also figured that
javac -d .\Food Fruit.java


it creates a Food folder above the already created Food folder.
 
s sivaraman
Ranch Hand
Posts: 59
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i almost got it man.
those are the proper ways for this kind of operation or still some other ways you have to do that?

i want to create the .class in different one from the currently working directory.
javac -d "C:\FFOutput" Fruit.java

i tried the above and its fine for me.
what do you think ?

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!