Java Virtual Machine

In java How can you execute a class file using
window's "java.exe" and not sun's java VM.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Leo EikelmanDirector, IT and Business DevelopmentCommented:
java.exe -classpath . HelloWorld

Leo EikelmanDirector, IT and Business DevelopmentCommented:
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:
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.


You need to either explicitly specify the path of the java.exe that you wish to use, or alter the system's PATH variable..
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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.