Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cant set paths in javac on Windows

32 views
Skip to first unread message

Dave Livesay

unread,
Dec 18, 2000, 7:46:59 PM12/18/00
to
I decided it was time to figure out how Java works on other platforms,
so today I tried to get Java working on a Windows machine. I downloaded
the SDK (1.3) installed it, and actually got a few programs to compile
and run. So I got adventurous and decided to organize the source and
class files in different folders and set the -d -classpath and
-sourcepath parameters in the javac compiler. I tried several
reasonable-looking interpretations based on the documentation, and when
I came up with something that seemed to act like it was working without
producing any error messages, I thought I was done, but when I tested it
I found that it was still defaulting to the current directory. I tried
using the relative path from the current folder:

bin\javac -d classes
bin\javac -classpath classes
bin\javac -sourcepath sources

and the full path:

bin\javac -d c:\jdk1.3\classes
bin\javac -classpath c:\jdk1.3\ classes
bin\javac -sourcepath c:\jdk1.3\ sources

What the heck am I doing wrong (aside from trying to do anything on Windows)?

I should point out that I know there are better developer tools. My
objective here is to better understand how the SDK works on Windows.

Thanks.

Paul Cody Johnston

unread,
Dec 18, 2000, 9:46:15 PM12/18/00
to
Dave Livesay <dliv...@telocity.com> wrote:
> I decided it was time to figure out how Java works on other platforms,
> so today I tried to get Java working on a Windows machine. I downloaded
> the SDK (1.3) installed it, and actually got a few programs to compile
> and run. So I got adventurous and decided to organize the source and
> class files in different folders and set the -d -classpath and
> -sourcepath parameters in the javac compiler. I tried several
> reasonable-looking interpretations based on the documentation, and when
> I came up with something that seemed to act like it was working without
> producing any error messages, I thought I was done, but when I tested it
> I found that it was still defaulting to the current directory. I tried
> using the relative path from the current folder:

> bin\javac -d classes
> bin\javac -classpath classes
> bin\javac -sourcepath sources

> and the full path:

> bin\javac -d c:\jdk1.3\classes
> bin\javac -classpath c:\jdk1.3\ classes
> bin\javac -sourcepath c:\jdk1.3\ sources

> What the heck am I doing wrong (aside from trying to do anything on Windows)?

Java on windows is pretty much the same animal as it is on other platforms. I
think you have some conception in your head that things are different. From
your examples it does not look like you are commfortable using the -d -classpath
-sourcepath options on any platform. The only main differences are the backslash
vs the forward slash and the semicolon vs the colon.

Assume you are in the directory "c:\My Documents\My Java" with subdirectories
"classes" and "sources". The following command should work (executed in the current
directory):

javac -d classes -classpath classes -sourcepath sources com\example\MyTest.java

You should never be compiling your classes into c:\jdk1.3 directory nor
need to specify it in the classpath.

Paul

Dave Livesay

unread,
Dec 18, 2000, 10:43:18 PM12/18/00
to
Paul Cody Johnston wrote:
>
> Java on windows is pretty much the same animal as it is on other
> platforms. I think you have some conception in your head that things
> are different.

I have a conception in my head that on a Mac, when you drop a source
file on javac, you get a dialog where you can set all the paths, click
"Okay" and it compiles.

> From your examples it does not look like you are commfortable using the
> -d -classpath -sourcepath options on any platform. The only main
> differences are the backslash vs the forward slash and the semicolon vs
> the colon.

I'm basically not comfortable with command lines, especially when
they're so poorly documented. So far I've only used the Mac tools and
various IDEs.

> Assume you are in the directory "c:\My Documents\My Java" with
> subdirectories "classes" and "sources". The following command should
> work (executed in the current directory):
>
> javac -d classes -classpath classes -sourcepath sources com\example\
> MyTest.java

I don't understand this at all. I'm trying to set default paths, not the
path to a specific source file. Is that not possible? Do you have to
specify the directory, source and class paths evey time you compile?
Sounds like the parameters are just there for scripting or something.

> You should never be compiling your classes into c:\jdk1.3 directory nor
> need to specify it in the classpath.

Any particular reason? I must have missed something in the Sun tutorial.
They have you compiling and running things from the same directory that
javac is in. They didn't say to move it anywhere.

Thanks for your help.

Trilogy Newsgroups

unread,
Dec 19, 2000, 7:02:09 PM12/19/00
to
except for the classpath parameter there is no such thing as a default...
the classpath as you already know can be set in the environment CLASSPATH
variable... the commandline version of the variable is used to enter
deviants from that value... the -d specifies where the generated classes end
up and the -sourcepath specifies the location of the source files besides
the current directory... the defaults for both options are the current
directory... To spell it out, if you do not specify anything, the compiler
assumes that you are using the system classpath, the source file is in the
current directory and the outputted classes should be placed in the current
directory...

i think these are pretty well documented in the Java tool documentation...
The reason you are uncomfortable would be because you are used to a
different environment... there are a zillion IDEs to choose from...
probably including the ones you might have used on Mac...

r

p.s: if you want to implement the functionality that you get on Windows, it
is pretty trivial to implement... necessity is the mother of invention...
:-)
"Dave Livesay" <dliv...@telocity.com> wrote in message
news:3A3ED93C...@telocity.com...

0 new messages