• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with -d option  RSS feed

 
Davie Lin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone, thanks for your input
I have j2sdk1.4.2_03 and jdk1.3.1_02 both in c drive and I type the following

I have src and class directories
the .java file is in src and I want the .class to be in class

I am sure my syntax is wrong for -d, can anyone give me suggestions?

Thank you
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming your directory structure looks like:

If you are compiling relative to the "src" folder (i.e "c:\project\src") and you want the MyClass binary (.class file) to end up in the "c:\project\class" folder you should call javac.exe as follows:

Where .. refers to the parent directory of the current directory and /class refers to its sub-directory called "class".


If you are compiling relative to the root folder ("c:\") and you want the MyClass binary (.class file) to end up in the "c:\project\class" folder you should call javac.exe as follows:

Where . refers to the current directory (./ may also be omitted)
[ March 21, 2008: Message edited by: Jelle Klap ]
 
Davie Lin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jelle Klap
would I need to include single quote for the directory since I am using Windows?
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a path contains one or more white spaces you need to surround it with double quotes. For example, let's rename the "project" folder to "my project" and see how it affects the javac.exe call relative to the file system root (C:\).

As the path specified for the -d option now contains a white space, it must be surrounded by double quotes, the same applies to the path specified as the source location.

Also note that the javac.exe call relative to the "src" folder (C:\my project\src) need not change, because renaming the "project" folder hasn't affected its path references, which still do not contain any white spaces. No double quotes needed in this case.

A final suggestion, try to avoid using any white spaces in path references where Java is concerned (this includes the installation path to the JDK), because, frankly, they're more trouble then they're worth.
[ March 21, 2008: Message edited by: Jelle Klap ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!