compiling from command line

Reply

Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

compiling from command line

 
0
  #1
Mar 25th, 2006
Hello everyone.

At the moment I'm compiling all my .java files in the same directory where the javac program is. I know this is a bad idea.

How do I link it from the command line and let's say export the .class files to another directory of my choice.

ThanQ
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 216
Reputation: hooknc is an unknown quantity at this point 
Solved Threads: 8
hooknc hooknc is offline Offline
Posting Whiz in Training

Re: compiling from command line

 
0
  #2
Mar 25th, 2006
I would recommend looking into Ant. It has a task called javac that should do what you're looking to do.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: compiling from command line

 
0
  #3
Mar 25th, 2006
Yeah I'll probably use that later, especially if it supports easy to make jar executables however, in the mean time do you know how to do it from the command line.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 216
Reputation: hooknc is an unknown quantity at this point 
Solved Threads: 8
hooknc hooknc is offline Offline
Posting Whiz in Training

Re: compiling from command line

 
0
  #4
Mar 25th, 2006
http://java.sun.com/j2se/1.5.0/docs/...ris/javac.html

it looks like the -d option is what you want.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: compiling from command line

 
0
  #5
Mar 31st, 2006
Ok I still can't do this?

Let's say this is where my javac program is:

  1. c:\j2sdk1.4.2_04\bin


And this is where I have written my program

  1. c:\java files\hello.java

How do I compile hello.java so that the class files appear in the same directory?


I assume these commands have something to do with it. Please help me
:cry:


  1. Usage: java [-options] class [args...]
  2. (to execute a class)
  3. or java [-options] -jar jarfile [args...]
  4. (to execute a jar file)
  5.  
  6. where options include:
  7. -client to select the "client" VM
  8. -server to select the "server" VM
  9. -hotspot is a synonym for the "client" VM [deprecated]
  10. The default VM is client.
  11.  
  12. -cp <class search path of directories and zip/jar files>
  13. -classpath <class search path of directories and zip/jar files>
  14. A ; separated list of directories, JAR archives,
  15. and ZIP archives to search for class files.
  16. -D<name>=<value>
  17. set a system property
  18. -verbose[:class|gc|jni]
  19. enable verbose output
  20. -version print product version and exit
  21. -version:<value>
  22. require the specified version to run
  23. -showversion print product version and continue
  24. -jre-restrict-search | -jre-no-restrict-search
  25. include/exclude user private JREs in the version search
  26. -? -help print this help message
  27. -X print help on non-standard options
  28. -ea[:<packagename>...|:<classname>]
  29. -enableassertions[:<packagename>...|:<classname>]
  30. enable assertions
  31. -da[:<packagename>...|:<classname>]
  32. -disableassertions[:<packagename>...|:<classname>]
  33. disable assertions
  34. -esa | -enablesystemassertions
  35. enable system assertions
  36. -dsa | -disablesystemassertions
  37. disable system assertions
  38. -agentlib:<libname>[=<options>]
  39. load native agent library <libname>, e.g. -agentlib:hprof
  40. see also, -agentlib:jdwp=help and -agentlib:hprof=help
  41. -agentpath:<pathname>[=<options>]
  42. load native agent library by full pathname
  43. -javaagent:<jarpath>[=<options>]
  44. load Java programming language agent, see java.lang.instrument

p.s is this version of java j2sdk1.4.2 an old version. Should I update. The reason I say that is because I can't get the code for Scanner util to work and the graphics g
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 902
Reputation: chrisbliss18 is an unknown quantity at this point 
Solved Threads: 23
chrisbliss18's Avatar
chrisbliss18 chrisbliss18 is offline Offline
Posting Shark

Re: compiling from command line

 
0
  #6
Mar 31st, 2006
All you need to do is add the location of your javac program to the path variable of your computer. That way, you can execute javac from anywhere. Using this method, all you need to do is change to your project folder and execute "javac file.java". To add a location to your path variable, right-click My Computer, select Properties, select the Advanced tab, and select Environment Variables. There should be two path variables: one for your user and one for the system. If you use multiple users, add to the System path variable; otherwise, modify your User path variable. To add a location to the path variable, select path, click Edit, go to the end of the variable value, add a semi-colon (semi-colons seperate locations in the path variable), and add the location you want to add (c:\j2sdk1.4.2_04\bin in your case). After you click OK on all the dialog windows, close any remaining command windows, reopen them, and you now can access the programs in the "c:\j2sdk1.4.2_04\bin" folder from anywhere.

If you don't want to set the path variable, you can always compile by referring to the javac program by it's full name while in your project folder, such as:
  1. c:\j2sdk1.4.2_04\bin\javac hello.java
Did we help you? Did we miss the point entirely? Update your thread and let us know.
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC