Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems getting basic Java programs to compile and run

Starting out with Java

Problems getting basic Java programs to compile and run

by  ackka  Posted    (Edited  )
Problems Compiling Java Programs, Applets and Applications using Sun Microsystems JDK1.1 Specific for Windows 9x systems

In tek-tips i have seen a large number of problems with simply trying to compile java programs. I think this is simply because alot of people do not understand basic dos commands which the JDK is written in.

Starting from the Installation

Download the JDK1.3 from java.sun.com
Go through the process of installing the JDK
It will install defalty to c:\jdk1.3
In Windows Explorer or Dos go to the c:\
Find c:\autoexec.bat
In windows, right click and left click on "edit"
In DOS, type edit c:\autoexec.bat

Find the line of text that says something like this
SET PATH = etc...

type at the end of this line ";c:\jdk1.3\bin" -
MUST LEAVE END OF LINE BLANK OR YOU MAY HAVE PROBLEMS :cool:

This basically adds all the executables in the c:\jdk1.3\bin to your windows or dos paths

Restart your computer-

To Compile a Program

make a simple java program - using a text editor such as notepad

ex...

class Test
{
public static void main( String args[] )
{
System.out.println("Java is a very neat language");
}
}

To get this program to compile correctely do.....
File ->Save As->

Your .java file has to be saved with the same name as your class
In the previous example the class was named Test, so when you type in the filename in notepad
you must save as Test.java ->>> To save correctely in notepad you must put quotes "" around the file name. This tells windows to save exactely as a .java file extension not the .txt you will get defaulty.

So where it says
File Name: type in exactly, with quotes--->>> "Test.java"

Then save.........

Next load DOS by typeing in Command at the run prompt
go to the directory where your file is stored

type
javac Test.java
if this goes okay and no error messages type
java Test

And on the screen should appear

Java is a very neat language

*******************************************
Here is how to do this in Windows 2000, same concept, Microsoft just changed the GUI a bit.
*******************************************
Hi i received your email about the Java FAQ i wrote, in Windows 2000 go to

the desktop->right click on "My Computer"-> go down to Properties

A Dialog Box called "System Properties" should appear, click on the

"Advanced" tab. Click on the button that says "Environment Variables".
Under "System Variables" if you scroll down you should see an item called

"Path", highlight it and click the "Edit" button. Then add the Java path to

that line.
ex.
E:\Perl\bin\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
;c:\jdk1.3\bin

This is what my path looks like, between each directory, you must place a ;

But make sure to leave the end of the path open.

*******************************************
*******************************************
You can also do this from the MS-DOS command line, except you will have to redo it each time you open a command prompt.

set path=%path%;c:\jdk1.3\bin
*******************************************
*******************************************


Well good luck :), java is an excellent programming language, you can create some really neat things..... if you have more questions my email is thomas.moses@gmail.com

later

tom
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top