Results 1 to 5 of 5
  1. #1
    carface is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default How do I run a .class file??

    Ok I am totally new to java. I have downloaded some files for an app that are .class files and one folder that is a META-INF file. How do I run a .class file as I am supposed to run a server by activating one of the class files and there is no .exe?

    I am using Windows xp Proffessional

  2. #2
    Hibernate's Avatar
    Hibernate is offline Senior Member
    Join Date
    Dec 2010
    Location
    Stockholm, Sweden
    Posts
    222
    Blog Entries
    9
    Rep Power
    4

    Default

    If you do not want to look into jar files you go to the Command Prompt and type:

    cd THE_PATH_WITH THE FILES
    java -cp . THE_MAINCLASS'_NAME

    If you do not know that class is the main class you should be
    able to find that in the manifest file (using Notepad or WordPad) in META-INF.


    If you downloaded an .jar file and extracted it go to the Command Prompt and type:

    cd THE_PATH_WITH THE FILES
    java -jar THE_JAR_FILE.jar
    Ex animo! Hibernate
    Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.

  3. #3
    carface is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default

    Hi thanks for your reply. I am getting the error message

    Unrecognised option : -cp.BlablaServ
    Could not create the Java virtual machine

    My files are on the C drive so in the command prompt i have typed cd C:\ then pressed enter.
    Then I have typed java -cp.BlablaServ

    I checked that the mainclass was BlablaServ.class

    Any help on this would be appreciated

  4. #4
    Hibernate's Avatar
    Hibernate is offline Senior Member
    Join Date
    Dec 2010
    Location
    Stockholm, Sweden
    Posts
    222
    Blog Entries
    9
    Rep Power
    4

    Default

    There should be spaces between -cp, . and BlablaServ:
    Java Code:
    java -cp . BlablaServ
    Ex animo! Hibernate
    Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.

  5. #5
    carface is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default

    Yeah that worked thanks. I created a jar file in the end and had to make sure the JDK was in the correct path. I went to Start>Control Panel>System>Advanced>Environment Variables and selected Path and entered where the JDK was which was C:\java\jdk1.5.0_06\bin\ for me.

Similar Threads

  1. Set file number on .class file
    By lmsf in forum Advanced Java
    Replies: 3
    Last Post: 03-24-2010, 06:38 AM
  2. converting java class file to exe file
    By satheeshtech in forum Advanced Java
    Replies: 5
    Last Post: 07-18-2009, 11:47 PM
  3. How to create .exe file using .class file
    By pradnya in forum New To Java
    Replies: 8
    Last Post: 04-18-2009, 12:50 AM
  4. Replies: 0
    Last Post: 05-13-2008, 06:16 AM
  5. Convert my class file into a exe file
    By carl in forum New To Java
    Replies: 1
    Last Post: 08-05-2007, 08:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •