Javac command line options

Hi team ,

I have a folder called as src in E:\ drive . In this folder Iam storing the all the .java files.  Iam trying to compile using the below options

I have an file  under a package com.businessobjects. I have issued the below comamnd to compile and create the .class file in the folder as per the package structure
Initially , I placed the .java file in E drive itself

e:\javac -d .

The folder structure as per package got created and the class file was placed in the E:\com\businessobjects.

After this step I decided to keep all the source files in E:\Src folder and then modified and java file and issued the below command

javac -sourcepath e:\src -d e:\src\ --> the .class file is not getting updated with the current version

The class file timestamp did not change . Again I tried to issue the below command

javac -sourcepath e:\src -d .

Now the .class file timestamp changed in e:\com\businessobjects folder .

First Question:

I want to know what happened when I gave -d with . and why it did not change the class file when I gave -d e:\src\.

Second Question:

I want to what is the use of -s option of Javac command ,

I tried to compile the code and store the source files in e:\src folder , but  got an error related to syntax file is in E:\

e:\javac -s src\
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kanti PrasadCommented:

I am not sure if there is an s option but if you don't specify any -d options, the class files will be put into directories according to the package structure, relative to the current directory. If you give an -d option, the class files will be put relative to the directory given by the option. Non-existing directories will be created here.

Here is a link that will give you all the options
sam_2012Author Commented:
Hi ,
Uploading the screen shot which shows the -s option
Kanti PrasadCommented:

If you question is why to use - d and - s then
          -d  is directory option to specify where the compiler should puts the generated .class file.
               For example:    javac -d classesdirName  -- means it will place in that dir.
                                       javac -d .   -- means it will place in the root dir as you mentioned .(dot)
          -s will  specifies where to place generated  source files
              For example:    javac -s classesdirName   -- means it will place in that dir.
                                         javac -s .   -- means it will place in the root dir as you mentioned .(dot)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sam_2012Author Commented:
Can we use -s option with -d ?
Kanti PrasadCommented:

I am not too sure, but you can try it

javac -d . -s .


javac -d  -s .
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.