• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • Last Modified:

Java Virtual Machine

In java How can you execute a class file using
window's "java.exe" and not sun's java VM.
0
Arun_Jain504
Asked:
Arun_Jain504
  • 2
1 Solution
 
Leo EikelmanCommented:
java.exe -classpath . HelloWorld

Leo
0
 
Leo EikelmanCommented:
Also, extended examples

To run a HelloWorld.class app, in the default package in a jar in C:\MyDir, use
java.exe -jar HelloWorld.jar HelloWorld

To run a HelloWorld.class app in C:\com\mindprod\mypackage, in package com.mindprod.mypackage, use
java.exe -classpath . com.mindprod.mypackage.HelloWorld

This will not work to run a HelloWorld.class app in C:\com\mindprod\mypackage, in package com.mindprod.mypackage:
C:\com\mindprod\mypackage
java.exe -classpath . com.mindprod.mypackage.HelloWorld
For that to work, you must use smartj instead of java.exe.

To run a HelloWorld.class app in C:\com\mindprod\mypackage, in a jar in package com.mindprod.mypackage, use
CD \AnyDir
java.exe -jar HelloWorld.jar com.mindprod.mypackage.HelloWorld

If for any reason the examples shown do not work with your version of java.exe, try various combinations of
com.mindprod.mypackage.HelloWorld, com/mindprod/mypackage/HelloWorld and com\mindprod\mypackage\HelloWorld.

Cheers,

Leo
0
 
InteractiveMindCommented:
You need to either explicitly specify the path of the java.exe that you wish to use, or alter the system's PATH variable..
0
 
jhanceCommented:
java.exe is Sun's JVM.  If you want to use Microsoft's JVM (I'm assuming that is your question) you must run JVIEW.EXE.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now