Tuesday, September 13, 2011

Tricky java question!!: locating .class files, incorporating .class files into a browser, ect. PLEAS HELP!?

I’ve downloaded the jdk-6u3-windows-i586-p installation program, %26amp; installed it successfully. By default it created a folder within program files called Java. With in that there are three folders: ';jdk-6u3-windows-i586-p';, ';jre1.6.0_03';, ';jre1.5.0_03';.

In the command line I changed the directory by typing:

“cd C:\ProgramFiles\Java\jdk1.6.0_03\bin”, %26amp; then successfully translated a ‘.java’ file to a ‘.class’ file by typing: “javac HelloWorld.java” into the command line. So at this point no errors have arisen and everything is working perfectly. I tested the program by typing “javac HelloWorld” %26amp; it worked. However there doesn’t seen to be a HelloWorld.class file in the current folder. By default where does the JDK translator place the ‘.class’ file? Also how is the ‘.class’ file integrated with a webpage page and ran when someone calls that site? I’m guessing you have to invoke a PHP script that tells the server to run the ‘.class’ file. This is all new to me, any help would be greatTricky java question!!: locating .class files, incorporating .class files into a browser, ect. PLEAS HELP!?
Correct Procedure -%26gt;

Firstly you should not use bin folder (where the java compiler, interpreter,... resides) to store your java files.

You have to set environment variables called PATH to tell the OS Java Virtual Machine where your compilers, etc are.

You have to set environment variables called CLASSPATH to tell the OS Java Virtual Machine where your classes/source code/programs reside.

Environment variables can be set from Control Panel - System - Go to Advanced Tab - then click Environment variables.

Append to PATH variable the location of Java installation directory bin folder. Please dont delete the existing value for these variables, just add a semicolon and then your path.

Append to CLASSPATH variable the location of folder in which you want to store your Java Programs. Please dont delete the existing value for these variables, just add a semicolon and then your path.

For more information, refer Java documentation or google it or sun.java.com.

I am just giving the right direction for exploration.



Answer to your question -%26gt;

It seems you are storing your java programs in the java installation directory. Java compiler, by default, stores the .class files in the same folder as .java if you dont use the '-d' switch with javac command. So ideally it should be there only, Just use windows search facility to find it on your computer.

For usage of the .class files with webpage, learn Java Applets. I cant paste an entire chapter here.

Good day bye

No comments:

Post a Comment