Java Virtual Machine

Posted on 2006-03-26
Last Modified: 2013-11-23
In java How can you execute a class file using
window's "java.exe" and not sun's java VM.
Question by:Arun_Jain504
    LVL 8

    Expert Comment

    by:Leo Eikelman
    java.exe -classpath . HelloWorld

    LVL 8

    Expert Comment

    by:Leo Eikelman
    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.


    LVL 25

    Expert Comment

    You need to either explicitly specify the path of the java.exe that you wish to use, or alter the system's PATH variable..
    LVL 32

    Accepted Solution

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
    Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
    This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now