Solved

Dont want to use javac -d option everytime on linux.

Posted on 2003-10-24
15
348 Views
Last Modified: 2012-08-13
Hi..
  I want to put a generated class file in working directory without -d option
for that can i need set any env variables.so that i did not need to put -d option everytime.

[root@x m_classes]# javac  /usr/apache/htdocs/mtool/Test.java

if  i will compile this file it will put my class file in mtool that i dont want to do. i want to put this file directly in to m_classes i know the -d option  but i dont want to use that option evrytime when i am compiling a java file.

plz suggest me with the help of example.


Thanks
Bipin

0
Comment
Question by:SoftGurus
  • 4
  • 3
  • 3
  • +4
15 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 9613095
Putting the class file into the current working directory is the default behaviour of the compiler anyway.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9613120
So, IOW why not just change to

usr/apache/htdocs/mtool

?
0
 
LVL 2

Expert Comment

by:f_98
ID: 9613187
if you work mostly at the command line, you may want to try learning and using a build tool like apache ant; among other things, it will let you set up the source and build directories for your project.
0
 
LVL 35

Expert Comment

by:girionis
ID: 9613195
>  but i dont want to use that option evrytime when i am compiling a java file.

  May we know why?
0
 

Author Comment

by:SoftGurus
ID: 9613271
Hi Friend
  When I Compile like this
    root@x m_classes]# javac  /usr/apache/htdocs/mtool/Test.java
   generated class file goes to  /usr/apache/htdocs/mtool directory
  but when i compile like this
    root@x m_classes]# javac -d    /m_classses
                                   /usr/apache/htdocs/mtool/Test.java
       My generated class file goes to that directory
   can I do this without  -d option by setting some path or environment variable in linux
   
   
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9613274
Why have you asked the same question under two different IDs?

750 points is a lot to spend on something like this.

The first thing I would do is close one of the questions and post a message on CS asking them to consolidate your accounts (or delete one).  It is strictly forbidden on EE to have more than one account.
0
 
LVL 35

Expert Comment

by:girionis
ID: 9613292
>  can I do this without  -d option by setting some path or environment variable in linux

  You can do it only if you have the source files into the folder which you want the class files to be (in other words .java and .class files are in the same directory) and then not use the -d option.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:SoftGurus
ID: 9613293
Hello Sir ..
  i am not using two different account. I saw the first quesion with same query and thats with the windows and i want same query with linux and its very urgent for me . plz if u have a solution then plz send it to me .i dont want to make a time pass with this is type of queries .

Thanks
Bipin
0
 
LVL 35

Expert Comment

by:girionis
ID: 9613309
> The first thing I would do is close one of the questions and post a message on CS asking them to consolidate your accounts (or delete one).

  I guess (s)he is probably some workmate/fellow student of the guy who asked the first question.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9613316
What you want to do cannot be done
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9613349
The easiest way to simplify things for yourself would be to use a shell script:

#!/usr/bin/bash

OUTDIR=/m_classes
javac -d$OUTDIR $*



Save the above as

jc.sh

and then do

./jc  /usr/apache/htdocs/mtool/Test.java
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9613350
My apologies if this is the case.

I'm sure you'll all agree that the greeting line and first sentence are extremely similar.

;-)
0
 
LVL 4

Accepted Solution

by:
brunomsilva earned 500 total points
ID: 9618016
why not:

alias javac ='javac -d'

i think it should be enough for you
0
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 9618898
I agree with f_98 - you should learn to use ant or make.  I can save you a great
deal of work (and excess typing) in the the future.

0
 

Author Comment

by:SoftGurus
ID: 9648708
Thanks  brunomsilva

Bipin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now