aspose file tools*
The moose likes Beginning Java and the fly likes compiler advice? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compiler advice?" Watch "compiler advice?" New topic
Author

compiler advice?

Heath Kondro
Greenhorn

Joined: Nov 12, 2008
Posts: 3
Just about to dive into JAVA. And would like to know if Sun JDK is too tough to download and install or should I go with free JBuilder from Borland? Any other free simple compilers that could be suggested?
And a bit confused about using text editor. Should I not write everything in a compiler, rather than text editor?
[ November 12, 2008: Message edited by: Heath Kondro ]
Brian Lang
Ranch Hand

Joined: Oct 21, 2008
Posts: 43
I would go with the official Sun JDK, v6 (current release version). It's relatively simple to install and configure. Let us know if you need any help or a point in the right direction.

Java SE downloads

Make sure you grab the JDK (v6 update 10) and the documentation (about halfway down the page).

You can skip the JRE download, as it's included in the JDK release.
[ November 12, 2008: Message edited by: Brian Lang ]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39828
    
  28
Welcome to JavaRanch

I am not familiar with the Borland product, but would advise you to get used to writing code with a text editor, preferable not Notepad (eg Notepad++ Notepad2 for Windows, Jedit for everything, or Kate and gedit on Linux).
There is too much of a "learning curve" to using an IDE, and most IDEs require a Java runtime be installed before they will work. Learn IDEs when you are more experienced.

Download the most recent version here; it is called Java SE Development Kit (JDK) 6 Update 10. Don't download anything with "JRE" in its name.
Find the installation instructions from the same page, and follow them to the letter, most particularly the bit about updating your PATH. The PATH is easier to update if you record the name of the folder you are using when you install Java. Best to update it permanently.
Check your CLASSPATH variable when you set PATH. If you have no CLASSPATH, leave it alone. If you do have a CLASSPATH, make sure it contains . or .; or ;. or ;.; somewhere. The . means "current directory."

Create a "java" directory in some convenient place on your computer and keep all your java work there. You may wish to add subdirectories as you accumulate more files.

Find the Java� Tutorials and look at the "getting started" and "common problems" sections.

And good luck with it
Heath Kondro
Greenhorn

Joined: Nov 12, 2008
Posts: 3
Thanks for the info.

JDK installed. However in the "C:\Program Files\Java" folder, I have the jdk folder, as well as 7 different jre folders.

Before I continue, you mentioned don't download any jre stuff, yet I seem to have it. Delete it, or ignore and continue?

Also, when I open the jdk folder, in the bin folder, there is an icon for javac, but I cannot open it. I assume this is because I have not set my path? Its seems SO more complicated than just clicking on an icon to open the compiler as I have done with C++ that I have downloaded. Maybe I'm getting ahead of myself....again, delete the jre folders or ignore and continue? Will do whatever you wiseones tell me to as I creep closer to the edge of the JAVA cliff.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39828
    
  28
Ignore any previously installed JRE folders unless you are short of space on your disc.
I presume you have got your path set up properly.
You don't access java.exe directly, you access it from the command line.
Since you are on Windows you can get it from start->all programs->accessories->command prompt. I copied command prompt as a shortcut to my desktop since I expected to use it frequently.

When the command line opens give it the following instructions

mkdir java
cd java
javac -version

That creates an empty directory called "java" which will either be in "my documents" or in "documents and settings." Also prints out the version number of your JDK installation; if you get something which looks like a version number (eg 1.6.0_10), success!

Open a text editor and copy a HelloWorld program from the "getting started" link I posted earlier. Save it under the title HelloWorld.java in your new java folder. Note that the name of the class and the name of the file might have to be exactly the same (with or without the .java bit).
Back to command prompt. Issue the following command

dir

You should see the name of your file. If it has acquired .txt as an extension, well I told you not to use NotePad, and rename it in Windows Explorer. Issue the following pair of instructions:

javac HelloWorld.java
java HelloWorld

and it ought to work. If you get any error messages, try the "common problems" file I quoted earlier.
Heath Kondro
Greenhorn

Joined: Nov 12, 2008
Posts: 3
Ran my HelloWorld program from my text editor and received.....

'javac' is not recognized as an internal or external command, operable command or batch file

Let me guess. My path is not set right?

I REALLY have done what I thought was setting everything up correctly, refering to Sun's instructions etc...

- went into Control Panel and set things in the Advanced Environment
- thought I set the Path with "set path=C:program FilesJavajdk1.6.0_10bin" in the Terminal Window
- changed directories with "cd C:\Documents and Settings\Heath\My Documents\Java"

I know I am missing something so basic that it is driving me insane! Plus probably making the experts who view this post roll their eyes. I'd really like to get over this hurdle so I can start some basic programming.
Help?
[edit]Disable smilies[/edit]
[ November 15, 2008: Message edited by: Campbell Ritchie ]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39828
    
  28
The error message "javac si not recognized etc" means a PATH problem in 99.9% of cases.

I presume you have put your java.exe in C:\Program Files\jdk1.6.0_10\bin?
Please check the PATH carefully; I shall edit you post to get rid of the smilies which make it hard to read. The tiniest spelling error will stop it working. And you have to open a new command window to activate the new PATH.

Alternative:
  • Open command prompt.
  • Navigate to your "Java" folder
  • Issue the following instruction: set PATH=C:\Program Files\jdk1.6.0_10\bin;%PATH%
  • Try again.
  • If it works like that, you will have to repeat the procedure whenever you open a new command window.
  • Look at the last post (from K Kiran Kumar) in this old thread, but you want to set the PATH the other way round, with ;%PATH% at the end. I think it is case-insensitive on DOS/Windows.
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 39828
        
      28
    Have you missed out the \ \ \ bits in the PATH? It won't work without.
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: compiler advice?