Your Development & Design Resource
Java Noob - How do I know it's working?!
06/06/2007 08:13 PM by Chris Toohey
So you've installed everything that you need to get you started on your 'Road to Java' - or have you? How do you know it's even working? You can download the JDKs from Java, and install all of the prerequisites for the Blackberry MDS and other 3rd-Party solutions... but even if you get all of those JDKs, Runtimes and whatnot installed properly - the system might not be setup in proper working order. In other words, you still won't be able to do anything after all that time spent downloading and installing because something is off.
I ran into this actually - no matter what I did, I couldn't get my
applications to compile and run properly. At first thinking it was the code
that I was writing, I opened up my copy of Head First Java and copied the Hello
World examples - simple
prinln examples. Still nothing. My
Java classes just wouldn't compile - I would get errors whenever I tried!
So, I started looking around - trying to see just what I had done wrong. After browsing, searching, and eventually posting in some forums, I finally had to reach out to Derik who had the solution for me - my System Environment Variable Path was not setup to use my JDK! Yeah, that went over my noob head big-time. It's basically this: my Java Compiler, Java Runtimes, etc. for all of my tools required that they work from outside of the bin directory.
Ok, I'll try to elaborate here (and I might get this off, so please - for
those who might know better - feel free to correct me):
I had installed Sun's JDK5 to C:\Program Files\Java\jdk1.5.0_11\. The compiler (javac), for example, is in the bin directory - C:\Program Files\Java\jdk1.5.0_11\bin All of my programs that use the compiler will need to know where it is. The way this is done, instead of telling each individual application/plug-in/etc. where my bin directory is, I set the System Environment Variable to state the bin path.
Ok - so, if you're still with me... something was off, and I didn't know what it was. So, I went to the command prompt for answers!
- I cd'ed into the bin directory:
cd C:\Program Files\Java\jdk1.5.0_11\bin.
- I typed in
javacand hit <enter>. This returned the syntax help -- great, the javac is working from the bin directory.
cd\brings me to the root of C...
- I typed in
javacand hit <enter>. This returned an error!
In order for this to work, the system needs to know where the bin directory is - and it apparently didn't! So here's what I did!
Right-click on My Computer, select Properties, which will open the System Properties Dialog. Go to the Advanced tab...
The Environment Variables button will open the... System Environment Variables Dialog. Yeah, pretty self explanatory there...
Now, on the System Environment Variables Dialog, you'll find the Path variable:
... where you'll modify/append the following:
Files\Java\jdk1.5.0_11\bin; (if you installed JDK5.0.11, in the default
An Ok, Ok, and another Ok gets you through the Dialogs, and a quick trip back to the command prompt will let you know if you're compiler is working now:
If you get the Java Compiler syntax help when you simply enter
javac from the root of C, you should be good to go!