Your first Java Program

 

 

This is for those of you who have never used Java before. You can write java programs in any text editor, I personally recommend Emacs, but notepad, MS Word, wordpad, etc are just fine too.

Unlike C++, every Java file has to have at least one class, even the file containing the main procedure. For writing this assignment, you shouldn’t need to write much more code than the one provided in this example—the only thing you need to figure out is the correct queries, creating a System DSN and looking up the ResultSet API.

Here are couple of setup steps. Machines in Sieg 232 lab are set-up with JDK 1.3.

I.                    Open a command prompt (StartàPrograms -> AccessoriesàCommand Prompt). Type in javac (command to compile a .java file). If you see a bunch of argument options go to step II. If you see a “command or file not found”, do the following: you will need to setup the path and classpath variables. Click Start->Run. Type sysedit. This command will bring up files like System.INI and Autoexec.bat. The file to edit is Autoexec.bat. Add the following lines:

a.       PATH=%Path%;D:\app\jdk1.3\bin (please double-check that D:\app\jdk1.3 is the correct location). 

b.      CLASSPATH=%classpath%;.

                                                               i.      Click File, Save , close everything and restart the machine. Step I should work now.

II.                 To compile your program type javac connect.java               This should create a .class file in the same directory as your original file. To run this executable type       java connect     (Note the lack of file extention).

 

Good luck.