Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Java classpath question and how to run a program from command line? Date: Mon, 28 Nov 2011 15:58:07 -0800 (PST) Organization: http://groups.google.com Lines: 42 Message-ID: <30751211.75.1322524687653.JavaMail.geo-discussion-forums@pruu5> References: <85f06dad-9e66-42ef-a232-d98c72832318@cc2g2000vbb.googlegroups.com> Reply-To: comp.lang.java.programmer@googlegroups.com NNTP-Posting-Host: 2620:0:1000:2404:224:d7ff:fe69:5838 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1322524715 4621 127.0.0.1 (28 Nov 2011 23:58:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 28 Nov 2011 23:58:35 +0000 (UTC) In-Reply-To: <85f06dad-9e66-42ef-a232-d98c72832318@cc2g2000vbb.googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2620:0:1000:2404:224:d7ff:fe69:5838; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10317 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.