Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Help with running class file

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with running class file

    I have downloaded some files for an app that are .class files and one folder that is a META-INF file.

    The 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 get this error message

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

    Can anyone help me with this as I cant see what I am doing wrong


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Help with running class file

    The correct syntax should be:
    java -cp class_path start_class_package.start_class
    where:
    class_path is the path to the base folder of all the class files.
    start_class_package is the package path to the start class (note that in Java the folder structure must match the package declaration)
    start_class is the class to start the program in (the one with the main method)

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help with running class file

    Ok thanks for the reply. Im totally new to Java just looked at it today so still getting to grips with some of the basic terms. I am a bit unsure about the package path.

    I have a .zip file called Rserver located on the root of the C drive and inside it there is 11 class files, 2 folders, META-INF which contains Manifest.mf and Images folder. The main class file is called BlablaServer.class

    How would I go about opening that file would it be something like this

    java -cp C:\ Rserver.BlablaServer

    I know this doesnt work though as I have tried it but looking for any further help on this
    Last edited by carface; December 30th, 2010 at 01:37 PM.

  4. #4
    Junior Member
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help with running class file

    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.

    Otherwise to run the class file through the command prompt each time just enter
    java -cp . BlablaServ
    Make sure you enter the spaces

Similar Threads

  1. how to import my own class in my .java file
    By amr in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 17th, 2010, 09:31 PM
  2. Replies: 5
    Last Post: November 13th, 2010, 01:53 PM
  3. Creating a class file
    By ipatch in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 8th, 2009, 07:19 PM
  4. running a class from another projects, reflection
    By led1433 in forum Object Oriented Programming
    Replies: 7
    Last Post: July 29th, 2009, 01:47 PM
  5. Truncated class file error
    By Koâk in forum Exceptions
    Replies: 4
    Last Post: June 23rd, 2009, 11:23 AM