running of java codes from dos window


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: running of java codes from dos window

  1. #1
    yomi Guest

    running of java codes from dos window


    hello everyone,
    i'm having problems running new java codes from my dos command line. i keep
    getting an error suggesting that the "main" file is not appropriately placed.
    (i use a visual cafe 2.0 package - symantec, i also have Borland J+ edition
    3.0 on same system). However, codes that have been compiled (class files
    created) b4 this error run well when i run them from the dos window.
    any sugestions would be appreciated.

    regards

    yomi


  2. #2
    Ray Mercer Guest

    Re: running of java codes from dos window

    Yomi,

    > i'm having problems running new java codes from my dos command line. i keep
    > getting an error suggesting that the "main" file is not appropriately placed.


    This problem is almost always caused by mistakes in your Classpath. Try doing
    "set CLASSPATH =" before running java or javaw on the class. That should reset
    the variable.

    HTH,
    Ray Mercer



  3. #3
    Al Guest

    Re: running of java codes from dos window


    Ray is exactly right. You can also include a classpath in your javac and
    java commands. For example,

    Change to the directory/subdirectory containing your Java code.

    Enter:
    javac -classpath . ProgName.java

    Notice the period after -classpath. It identifies your currect subdirectory.
    This saves from a lot of typing and potentially entering an incorrect classpath.

    If you have a jar/zip that contains API's you're using, you need to include
    them in your classpath as well. This example shows what you would configure
    if you were using Oracle's (older) JDBC thin driver:

    Enter:
    javac -classpath "c:\Oracle JDBC\classes12.zip";. ProgName.java

    Notice that I put the classpath within quotes. This is because there are
    spaces in the directory name, "Oracle JDBC". You'll also notice that I also
    included the current directory of where ProgName.java is located by ending
    the classes12.zip classpath with a semicolon and entering a period to signify
    the current directory.

    The same -classpath information applies to when you are using java to run
    your bytecode.

    If you prefer to use a set classpath= statement as Ray suggested, the same
    principles apply.

    "Ray Mercer" <raymer@mvps.org> wrote:
    >Yomi,
    >
    >> i'm having problems running new java codes from my dos command line. i

    keep
    >> getting an error suggesting that the "main" file is not appropriately

    placed.
    >
    >This problem is almost always caused by mistakes in your Classpath. Try

    doing
    >"set CLASSPATH =" before running java or javaw on the class. That should

    reset
    >the variable.
    >
    >HTH,
    >Ray Mercer
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center