Click to See Complete Forum and Search --> : what is the purpose of the .class file [resolved]
zmerlinz
Dec 5th, 2001, 12:17 PM
i was just wondering when you compile your program you have a .class file, but when you goto run your program you are running the .java file, so what pupose does the .class file have ???
there must be some point though yeah ??
crptcblade
Dec 5th, 2001, 12:30 PM
Actually, you are not running the .java file, you are running the .class file. The .java file is just the ASCII text source code. The .class file is the compiled code, like a .exe file.
:)
zmerlinz
Dec 5th, 2001, 01:36 PM
but surely it is the java file that you are running because to run it you type
java Something.java
and not
java Something.class
and there isn't any ascii code in the class file, well none that i saw ??
Crazy_bee
Dec 5th, 2001, 01:44 PM
All you type is java Something not java Something.java. If you are using JDK that is. With JDK you compile with javac Something.java then to run you use java Something
zmerlinz
Dec 5th, 2001, 01:53 PM
oh yeah i forgot about that thanks, i am new to java btw :p
but still i can't see a use for the .class file
can you actualy compile a java program to an exe at all ??
if so how ?
Crazy_bee
Dec 5th, 2001, 01:56 PM
I'm new to it also. I believe you need a 3rd party software to convert to exe. Unless Borland has something built into Jbuilder.
crptcblade
Dec 5th, 2001, 02:12 PM
Yes there are apps to convert class files to exe's. I started a thread about that a while ago, I'll see if I can find it.
The reason that java files are compiled into class and not exe files, is because exe format is OS-dependant, and that would undermine the whole purpose behind Java's platform independence.
When you type in "java Something" the JVM kicks off and runs the class file. The JVM interprets the class file's code, and translates it to a form that the OS understands.
:)
crptcblade
Dec 5th, 2001, 02:14 PM
http://www.vbforums.com/showthread.php?s=&threadid=95603
;)
sail3005
Dec 5th, 2001, 06:18 PM
Yeah, the class file is the byte code. It is then run by the VM.
zmerlinz
Dec 5th, 2001, 08:18 PM
ok then cheers guys :) :cool:
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.