Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Java classpath question and how to run a program from command line? Date: Mon, 28 Nov 2011 23:08:47 +0100 Lines: 41 Message-ID: <9jif3fFmdrU1@mid.individual.net> References: <85f06dad-9e66-42ef-a232-d98c72832318@cc2g2000vbb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net jvpPmZOrldPGe3Lj8UE7Egq4czKSdLBM8JKUNqp7r7r5dyTJI= Cancel-Lock: sha1:wbVN2UFPFGAtnSwk/6bh+aQOniA= User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 In-Reply-To: <85f06dad-9e66-42ef-a232-d98c72832318@cc2g2000vbb.googlegroups.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10312 On 11/28/2011 10:50 PM, www wrote: > Hi: > > 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) > 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 > > Can you help me on how to run it from the command line? Can you show the error? > 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. If you are starting a Windows JVM chances are that you need to pass Windows paths since /cygdrive cannot be resolved in Windows land. See utility "cygpath". Cheers robert