dominoGuru.com

Your Development & Design Resource

Java Noob - How do I know it's working?!

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!

  1. I cd'ed into the bin directory: cd C:\Program Files\Java\jdk1.5.0_11\bin.
  2. I typed in javac and hit <enter>. This returned the syntax help -- great, the javac is working from the bin directory.
  3. Now, cd\ brings me to the root of C...
  4. I typed in javac and 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...

System Properties

The Environment Variables button will open the... System Environment Variables Dialog. Yeah, pretty self explanatory there...

System Environment Variables

Now, on the System Environment Variables Dialog, you'll find the Path variable:

System Environment Variables - Path

... where you'll modify/append the following: C:\Program Files\Java\jdk1.5.0_11\bin; (if you installed JDK5.0.11, in the default location).

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:

javac 
at the Command Prompt

If you get the Java Compiler syntax help when you simply enter javac from the root of C, you should be good to go!


About the author: Chris Toohey

Thought Leadership, Web & Mobile Application Development, Solutions Integration, Technical Writing & Mentoring

A published developer and webmaster of dominoGuru.com, Chris Toohey specializes in platform application development, solutions integration, and evangelism of platform capabilities and best practices.



More from dominoGuru.com


dominoGuru.com is powered by IBM Notes Domino XPages & hosted by Prominic.NET

Contact Us

Use our Contact / Feedback form or one of these email addresses:

Creative Commons License

Except where otherwise noted, dominoGuru.com by Chris Toohey is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.