Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Run anywhere

 
Qusay Jaafar
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can execute a class file into a computer java 1.X not installed with it?
I mean, to run a class file you type in command promt the following:
java MyClassFile
but if jdk1.X not installed in the computer, the (java MyClassFile) will not recognize.
So, What it means compile once, run anywhere?
is it necessary to install JDK1.X?
thanks
 
Steve Schowiak
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't, unless you have the Java Virtual Machine installed on the computer you want to run the class on.
COMPILE ONCE means the program is compiled into bytecode that is in a .class file.

'RUN ANYWHERE' means that a Java .class file will run on any machine PROVIDED that machine has the Java Virtual Machine installed on it.
Sun makes the JVM for many different platforms available for free download. It's called RTE, or Run-Time Environment, which among other things, contains the JVM.
The JVM just sits there doing nothing until you type 'java myclassfile' on the command line.
Cool, ain't it?
 
Steve Schowiak
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot to mention:
The JDK or SDK is a download from Sun that will give you all the command-line tools to compile, run, document, and debug Java programs.
The RTE is a download that provides tools that work in the background when your web browser is running, so you can see applets and stuff. It also has the java command that lets you run class files from the command line.
The Sun 1 Studio is a seperate download that has a cool IDE in it. It includes the JDK/SDK.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic