Re: Java classpath question and how to run a program from command line?

Discussion in 'Java' started by Lew, Nov 28, 2011.

  1. Lew

    Lew Guest

    www wrote:
    > Sorry. I am confused about how to run a Java class from command line(I
    > can run it from Eclipse). I use Cygwin on Windows 7.
    > This Java source file is /cygdrive/d/project/src/A/B/C/
    > MainWindow.java
    > The class file(MainWindow.class) is located at /cygdrive/d/project/bin/
    > A/BC/MainWindow.class (compiled by Eclipse)


    I assume there's supposed to be a slash between that "B" and "C".

    > MainWindow.java package is:
    >
    > package A.B.C;
    >
    > The following JAR files are also needed to run the program: /cygdrive/
    > d/project/libs/*.jar
    >
    > In Cygwin command window, "echo $CLASSPATH" does not show anything, so
    > CLASSPATH has not been set.
    >
    > Now in Cygwin command window, I am at /cygdrive/d/project/bin, I typed
    > the command below, but it didn't work:
    >
    > java -classpath /cygdrive/d/project/libs;. A.B.C.MainWindow


    java -classpath 'd:/project/libs/*;." A.B.C.MainWindow

    You don't get the JARs just by referencing the directory. You need to read the documentation on classpaths.

    --
    Lew

    > Can you help me on how to run it from the command line?
    >
    > I also tried to set up CLASSPATH in .bashrc file beforehand:
    > export CLASSPATH=/cygdrive/d/project/libs/;/cygdrive/d/project/bin
    > I am confused: should I separate them by ";" or ":" ?
    > I tried both ways, none of them is working: ". .bashrc" command
    > complains or no complains, but MainWindow still cannot be run.
    >
    > Thank you very much.
    Lew, Nov 28, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gabe
    Replies:
    3
    Views:
    1,068
  2. Thomas Kellerer
    Replies:
    5
    Views:
    34,566
    Nomak
    Apr 13, 2005
  3. John B. Matthews

    Re: Java command line classpath wildcards

    John B. Matthews, Dec 12, 2008, in forum: Java
    Replies:
    0
    Views:
    538
    John B. Matthews
    Dec 12, 2008
  4. Tom Anderson
    Replies:
    0
    Views:
    1,989
    Tom Anderson
    Dec 13, 2008
  5. Lew
    Replies:
    1
    Views:
    473
Loading...

Share This Page