7-17-98
murle kumar
murle_k@hotmail.com
Iam learning JAVA programming. Learning JAva on SUN'S site is a bit difficult iam finding. I don't how to compile the the programme i have written first.
Okay i have a JAVA progaramme i don't know anything about Jawa. How to run that programme. Like writing a html programme and saving the file as html we can run the programme. Likewise how can i run the programme? Please kindly help me in this.Thnks
Regards
| Responses:
7-18-98 The "Hello World" application and the "Hello World" applet are good for figuring out what I believe you are asking. I prefer using DOS when working with Java because it is easy for me to create, edit, and save java files and html files, and use the Java compiler and appletviewer. I create files using the DOS editor so that I can easily save them with any extension name I choose. The Java source file must have a .java extension for the compiler to work. The compiler and the Java source file must be in the same directory so I do all of my work in the directory named "bin" of the Java Development Kit because this is where the compiler and other development programs are at. The path on my PC, which is probably the same on yours, is C:\jdk1.1.5\bin>. Once I am here, I type edit, press enter, and type in the Java source code. I save the file, giving it the same name as the class in the Java source code, add the .java extension, and then close the editor. At the DOS prompt, I type javac filename.java and press enter
to compile the file. When the compiler is done, the DOS prompt returns.
The compiler creates a new file with the same name as the Java source file,
but with a different extension, .class. It is this .class file that you
want to run.
|
If the program is an application, to run it, I type java filename at the DOS prompt. Note that the extension is dropped at this point. The interpreter assumes that you want to run a .class file. If the program is an applet, I must create an HTML file that the applet
will run in. I create my HTML file in the same "bin" directory that I've
been working in. The "Hello
World" applet section shows the HTML code necessary.
Perry Smith |
Load your text editor, write your code. Save it in a
file, test.java fex. You need to have JDK installed
in order to compile, if you have, add the line
SET PATH=C:\somedir\JDK12\bin %PATH% in your autoexec.bat,
now you can invoke the javac (java compiler) from any dir.
Go to the dir in which you saved test.java and type
javac test
You're now compiling. To run it, type java test
There are tons of tutorials on the net, good luck :)
Morten