Where is javac.

G

george.e.sullivan

Ok, so I want to learn some java and I run to the library and grab "The
Complete Reference, Java 2 Fifth Edition" from Osborne, copyright 2002.
Ok, its a little old. I get to the code for my first Java Program,
type it up in notepad and then the books wants me to do:

javac example.java

Windows complains it doesn't have a javac. So off to Sun I go for the
latest Java stuff like j2sdk-1_4_2_11 and jdk-1_5_0_07 and install
that. Still no javac. Has things changed since 2002 and javac is no
longer used? Where is javac?

Thanks
the ultimate novice :)
 
L

Lee Weiner

Ok, so I want to learn some java and I run to the library and grab "The
Complete Reference, Java 2 Fifth Edition" from Osborne, copyright 2002.
Ok, its a little old. I get to the code for my first Java Program,
type it up in notepad and then the books wants me to do:

javac example.java

Windows complains it doesn't have a javac. So off to Sun I go for the
latest Java stuff like j2sdk-1_4_2_11 and jdk-1_5_0_07 and install
that. Still no javac. Has things changed since 2002 and javac is no
longer used? Where is javac?

Probably right where it belongs, in the bin directory under the jdk directory.
The reason Windows can't find it is because you never set your PATH to include
this directory. When you downloaded the jdk's, did you also look at or
download the installation instructions? In order to execute the javac program
from any folder, you have to modify your PC's PATH environment variable to
include the jdk bin directory.

Lee Weiner
lee AT leeweiner DOT org
 
L

Lionel

Lee said:
Probably right where it belongs, in the bin directory under the jdk directory.
The reason Windows can't find it is because you never set your PATH to include
this directory. When you downloaded the jdk's, did you also look at or
download the installation instructions? In order to execute the javac program
from any folder, you have to modify your PC's PATH environment variable to
include the jdk bin directory.

As a beginner you may be best off using an IDE that will take care of a
lot of this. Maybe try Netbeans.

At the same time it is important to learn to use the commandline.

Lionel.
 
L

Luc The Perverse

Lionel said:
As a beginner you may be best off using an IDE that will take care of a
lot of this. Maybe try Netbeans.

I would disagree with netbeans - I found that as a n00b it complicated my
life, not simplified it.

Assuming you use windows I would suggest GEL http://www.gexperts.com/
It is free, and it does very little except give an interface and an output
window. It is not perfect though, sometimes it crashes. (Never seen
NetBeans do that.)

The reason I like GEL is because you can work with and compile and run
single files, not having to declare some project, or build scripts etc.

Command line is fine once you get your environment variables set - and I
think that is where every beginner should start. My first Java programming
was on a remote linux machine through an SSH tunnel. It was fun!
 
L

Lionel

Luc said:
The reason I like GEL is because you can work with and compile and run
single files, not having to declare some project, or build scripts etc.

Good point. I had forgotten that you need to create projects, this can
be confusing sometimes as a new user. I haven't created a new project in
a couple of years, I've just been working on the one project since
Netbeans 3.x :).
Command line is fine once you get your environment variables set - and I
think that is where every beginner should start. My first Java programming
was on a remote linux machine through an SSH tunnel. It was fun!

lol 8-|

Lionel.
 
P

P.Hill

Lionel said:
Good point. I had forgotten that you need to create projects,

So what so confusing about creating an area to place files.
Certainly a set of Chapter 1, Chapter 2 etc. projects seems like
very logical constructs to me and should to a newbie once they realize
they'd like to keep their first program safe before messing with their
second one.

Oh yes, I don't forget to complete the installation instructions
for a JDK download, you'll probably need that anyway regardless of what
IDE you use.

-Paul
 
L

Lionel

P.Hill said:
So what so confusing about creating an area to place files.
Certainly a set of Chapter 1, Chapter 2 etc. projects seems like
very logical constructs to me and should to a newbie once they realize
they'd like to keep their first program safe before messing with their
second one.

Well yeah. If you take your time you can figure it out. But it is often
a stumbling block for newbies. They tend to get impatient and try some
totally different approach.

Oh yes, I don't forget to complete the installation instructions
for a JDK download,
Huh?

you'll probably need that anyway regardless of what
IDE you use.

You can get both with Netbeans . . . I'm sure there's others that do the
same.
 
I

IchBin

Luc said:
I would disagree with netbeans - I found that as a n00b it complicated my
life, not simplified it.

Assuming you use windows I would suggest GEL http://www.gexperts.com/
It is free, and it does very little except give an interface and an output
window. It is not perfect though, sometimes it crashes. (Never seen
NetBeans do that.)

The reason I like GEL is because you can work with and compile and run
single files, not having to declare some project, or build scripts etc.

Command line is fine once you get your environment variables set - and I
think that is where every beginner should start. My first Java programming
was on a remote linux machine through an SSH tunnel. It was fun!

Yes, as LTP has mention GEL. I agree with him and I also use it. I use
it for the same reason. For quick stuff but I use Eclipse and Netbeans
on everything else.

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
I

IchBin

Lionel said:
Good point. I had forgotten that you need to create projects, this can
be confusing sometimes as a new user. I haven't created a new project in
a couple of years, I've just been working on the one project since
Netbeans 3.x :).


lol 8-|

Lionel.

But with GEL you can create Projects if you want to ...

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
P

P.Hill

Lionel said:
P.Hill said:
Lionel said:
Good point. I had forgotten that you need to create projects,

So what[]s] so confusing about creating an area to place files.
Certainly a set of Chapter 1, Chapter 2 etc. projects seems like
very logical constructs to me and should to a newbie once they realize
they'd like to keep their first program safe before messing with their
second one.

Well yeah. If you take your time you can figure it out. But it is often
a stumbling block for newbies. They tend to get impatient and try some
totally different approach.

So using the command line and getting a classpath correct which is
provided by an IDE (just like the IDE may provides a JDK as you point
out) is supposed to be conceptually less difficult than picking a place
to organize files? Hmm, I'm not convinced.

Sorry typo. "[and] don't forget to complete the installation ..."
Why? (1) Because learning to run something from the command line is a
useful bit of knowledge unless all programs are just learning exercises;
(2) It is good to know how to run something "by hand" even if everything
is just an exercise.
You can get both with Netbeans . . . I'm sure there's others that do the
same.

Of course modified by the need to separately agree to the EULA for the
JDK which typically requires the JDK be installed first. This is a
negative to a newbie using jumping right to an IDE whatever the IDE.

whatever,
-Paul
 
G

Guest

Ecllipse is a better choice also . first it is free. and easier this
is important to a freshman.
 
L

Luc The Perverse

P.Hill said:
So using the command line and getting a classpath correct which is
provided by an IDE (just like the IDE may provides a JDK as you point out)
is supposed to be conceptually less difficult than picking a place to
organize files? Hmm, I'm not convinced.

java -cp . MyClass

Not too hard :) And yes - it took me a while the first time. But I had a
book to go off of. And I DID find this easier than trying to figure out
how to make netbeans work.
 
O

Oliver Wong

P.Hill said:
Lionel said:
P.Hill said:
Lionel wrote:

Good point. I had forgotten that you need to create projects,

So what[]s] so confusing about creating an area to place files.
Certainly a set of Chapter 1, Chapter 2 etc. projects seems like
very logical constructs to me and should to a newbie once they realize
they'd like to keep their first program safe before messing with their
second one.

Well yeah. If you take your time you can figure it out. But it is often a
stumbling block for newbies. They tend to get impatient and try some
totally different approach.

So using the command line and getting a classpath correct which is
provided by an IDE (just like the IDE may provides a JDK as you point out)
is supposed to be conceptually less difficult than picking a place to
organize files? Hmm, I'm not convinced.

If you're a complete newbie, and you don't even know what the concept of
compilation refers to, then I think the command line is easier. Why? Because
most tutorials will provide explicit step-by-step instructions on how to
compile from the command line from the three major OSes (Windows, Linux and
MacOSX). Most tutorials don't bother with instructions for IDEs because
there's so many of them, and even within a given product series, they vary
very quickly (Eclipse 3.2 has a whole bunch of new features that Eclipse 3.1
didn't have, for example).

Plus, the command line tends to have a lot less state than an IDE. With
Eclipse, for example, you have to make sure that you're in the "Java
perspective". You have to hope that the perspective is reset to its default
so that if you say some view is on the left hand side, it really will be on
the left hand side, and not on the right hand side.

- Oliver
 
G

george.e.sullivan

WOW and Double WOW. I never dreamed my question would create such a
thread. I am honored by all your reponses. I will take to heart your
many suggestions and comments. I don't know why my one computer seemed
to have trouble installing Java. Nothing...absolutely nothing... was
in the bin directory and there were no "hidding" settings active for
the window.

SO I tried it on another and there it was. Go figure.......

Now perhaps someone can tell me a better book to use. The first
example in this current book ( see the title at the start of this
thread) is coded like this:

/*
Comments omitted
*/
class Example {
// Another comment
public static void main (string args[ ] ) {
System.out.println("This is a simple Java Program.");
}
}

And this is the error I get when I run javac example.java:
Exception in thread "main" java.lang.NoClassDefFoundError:
example/class

I don't want to have to spend any time debugging. It just aught to
work when you are learning. So what is a better book that is perhaps
more up-to-date. My has a copyright of 2002. IT is sort of
discouraging when even the book examples don't work. In some places in
the example it was hard to tell if a space existed between some things
like "main(string" or "main (string" but I got the error
regardless.

Thanks again to all
George Sullivan

Oliver said:
P.Hill said:
Lionel said:
P.Hill wrote:

Lionel wrote:

Good point. I had forgotten that you need to create projects,

So what[]s] so confusing about creating an area to place files.
Certainly a set of Chapter 1, Chapter 2 etc. projects seems like
very logical constructs to me and should to a newbie once they realize
they'd like to keep their first program safe before messing with their
second one.

Well yeah. If you take your time you can figure it out. But it is often a
stumbling block for newbies. They tend to get impatient and try some
totally different approach.

So using the command line and getting a classpath correct which is
provided by an IDE (just like the IDE may provides a JDK as you point out)
is supposed to be conceptually less difficult than picking a place to
organize files? Hmm, I'm not convinced.

If you're a complete newbie, and you don't even know what the concept of
compilation refers to, then I think the command line is easier. Why? Because
most tutorials will provide explicit step-by-step instructions on how to
compile from the command line from the three major OSes (Windows, Linux and
MacOSX). Most tutorials don't bother with instructions for IDEs because
there's so many of them, and even within a given product series, they vary
very quickly (Eclipse 3.2 has a whole bunch of new features that Eclipse 3.1
didn't have, for example).

Plus, the command line tends to have a lot less state than an IDE. With
Eclipse, for example, you have to make sure that you're in the "Java
perspective". You have to hope that the perspective is reset to its default
so that if you say some view is on the left hand side, it really will be on
the left hand side, and not on the right hand side.

- Oliver
 
I

IchBin

WOW and Double WOW. I never dreamed my question would create such a
thread. I am honored by all your reponses. I will take to heart your
many suggestions and comments. I don't know why my one computer seemed
to have trouble installing Java. Nothing...absolutely nothing... was
in the bin directory and there were no "hidding" settings active for
the window.

SO I tried it on another and there it was. Go figure.......

Now perhaps someone can tell me a better book to use. The first
example in this current book ( see the title at the start of this
thread) is coded like this:

/*
Comments omitted
*/
class Example {
// Another comment
public static void main (string args[ ] ) {
System.out.println("This is a simple Java Program.");
}
}

And this is the error I get when I run javac example.java:
Exception in thread "main" java.lang.NoClassDefFoundError:
example/class

I don't want to have to spend any time debugging. It just aught to
work when you are learning. So what is a better book that is perhaps
more up-to-date. My has a copyright of 2002. IT is sort of
discouraging when even the book examples don't work. In some places in
the example it was hard to tell if a space existed between some things
like "main(string" or "main (string" but I got the error
regardless.

Thanks again to all
George Sullivan

Oliver said:
P.Hill said:
Lionel wrote:
P.Hill wrote:

Lionel wrote:

Good point. I had forgotten that you need to create projects,
So what[]s] so confusing about creating an area to place files.
Certainly a set of Chapter 1, Chapter 2 etc. projects seems like
very logical constructs to me and should to a newbie once they realize
they'd like to keep their first program safe before messing with their
second one.
Well yeah. If you take your time you can figure it out. But it is often a
stumbling block for newbies. They tend to get impatient and try some
totally different approach.
So using the command line and getting a classpath correct which is
provided by an IDE (just like the IDE may provides a JDK as you point out)
is supposed to be conceptually less difficult than picking a place to
organize files? Hmm, I'm not convinced.
If you're a complete newbie, and you don't even know what the concept of
compilation refers to, then I think the command line is easier. Why? Because
most tutorials will provide explicit step-by-step instructions on how to
compile from the command line from the three major OSes (Windows, Linux and
MacOSX). Most tutorials don't bother with instructions for IDEs because
there's so many of them, and even within a given product series, they vary
very quickly (Eclipse 3.2 has a whole bunch of new features that Eclipse 3.1
didn't have, for example).

Plus, the command line tends to have a lot less state than an IDE. With
Eclipse, for example, you have to make sure that you're in the "Java
perspective". You have to hope that the perspective is reset to its default
so that if you say some view is on the left hand side, it really will be on
the left hand side, and not on the right hand side.

- Oliver

To give you a little advice. While you are learning, start to compliment
it by using Google. That is, Google the *groups*. This error is a
classic first time error a person learning the language makes.

Example for this error Google:

thread "main" java.lang.NoClassDefFoundError:

You will come up with tons of other people with the same problem when
they start Java.

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
S

Steve

Complement: goes well with, put to good use in conjunction with, etc.

Compliment: "Gee, you look nice today!"

Sorry, but that's a pet peeve of mine.

And how about twos-compliment: "Gee, you both look nice today!"
 
L

Luc The Perverse

Steve said:
Complement: goes well with, put to good use in conjunction with, etc.

Compliment: "Gee, you look nice today!"

Sorry, but that's a pet peeve of mine.

And how about twos-compliment: "Gee, you both look nice today!"

Shit I didn't know that - and English is supposed to be one of my strong
suits.
 
L

Luc The Perverse

And this is the error I get when I run javac example.java:
Exception in thread "main" java.lang.NoClassDefFoundError:
example/class

I don't want to have to spend any time debugging. It just aught to
work when you are learning. So what is a better book that is perhaps
more up-to-date. My has a copyright of 2002. IT is sort of
discouraging when even the book examples don't work. In some places in
the example it was hard to tell if a space existed between some things
like "main(string" or "main (string" but I got the error
regardless.

While I understand your frustration, I'm not entirely sure that I agree with
you. A large portion of your time, especially while you are learning, is
going to be spent on debugging.

Of course, not having the very first example work adds a new level. You
can only be completely green once.

But don't give up. You won't be able to have fun with something until you
achieve a certain level of comfort and familiarity. (Remember, exciting is
not always the same thing as fun.)
 
J

Juha Laiho

Now perhaps someone can tell me a better book to use.

[to learn Java from the start]

I've found The Java Tutorial pretty nice. For what you seem to be doing
at the moment, see:
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html

This seems to cover pretty much the steps you've found problematic so
far, with suggestions on what to do on certain trouble spots (javac
or java not found, NoClassDefFound errors, ...).

And the tutorial goes pretty far, for "desktop java"; what it doesn't
cover is servlets and other web server-side issues, but then, once you
get the hang of Java in general, those shouldn't be that hard to
pick up (if that is what you want to do).
 
G

george.e.sullivan

LOL!!!! You guys are too much. There is a certain perverse humor I
detect with you programmer types. I hope to join your elite bunch
soon. "Alrighty now" as Jim Carrey says I'll move on to the Sun
Getting Started stuff and come back to the book example when I know
what it is really trying to tell me. As Q says in Star Trek TNG "See
you out there...."

george
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,216
Latest member
topweb3twitterchannels

Latest Threads

Top