Hello, can anyone tell me how I can convert a .java file into .class file with an executable bytecode.
Thanks
Hello, can anyone tell me how I can convert a .java file into .class file with an executable bytecode.
Thanks
To get a .class file you have to compile the .java file.
The command for this is javac. The manual for this is found here (Windows)
In short:
javac File.java
Use the javac program that comes with the JDK (visit java.sun.com if you don't have it). The installer does not automatically add javac to your system path, so you'll need to add the bin directory of the installed path to your system path before you can use it easily.
A .java file is the code file.
A .class file is the compiled file.
It's not exactly "conversion" - it's compilation. Suppose your file was called "herb.java", you would write (in the command prompt):
javac herb.java
It will create a herb.class file in the current folder.
It is "executable" only if it contains a static void main(String[]) method inside it. If it does, you can execute it by running (again, command prompt:)
java herb
I would suggest you read the appropriate sections in The Java Tutorial from Sun:
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html
After compiling it you can jar it.
java -jar AppName.jar
http://windowstipoftheday.blogspot.com/2005/10/setting-jar-file-association.html