Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #10327

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

From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Java classpath question and how to run a program from command line?
Date 2011-11-29 07:43 -0800
Organization http://groups.google.com
Message-ID <5431520.470.1322581431774.JavaMail.geo-discussion-forums@prij11> (permalink)
References <85f06dad-9e66-42ef-a232-d98c72832318@cc2g2000vbb.googlegroups.com> <ed80ba1f-864b-4fda-b619-abcd90f6ce2c@gl2g2000vbb.googlegroups.com> <bb1769d4-8638-4f3c-9778-0f11b0b4956b@m7g2000vbc.googlegroups.com>

Show all headers | View raw


www wrote:
>> Now, I can make it work:
>>
>> java -classpath "/cygdrive/d/project/libs/*;." A.B.C.MainWindow
>>
>> by adding the pair of " on the parameter after -classpath AND libs/*,
>> not libs only. Both corrections are needed to make it work.

Well, duh.

Except you forgot to switch to Windows nomenclature ("D:/", not "/cygdrive/d/").

You need the quotes because bash sees the semicolon as a statement terminator.  Remember?  You could also have escaped the semicolon with a backslash instead of using quotes.

You need the asterisk for the reason stated upthread.  Did you review the rules for classpath specification as two respondents suggested?  It's very basic stuff - the JARs must be called out explicitly, or since recently with a wildcard.  You don't pick up JARs just by listing the directory.  As stated in the tutorials and documentation.  Which you should study.

> Sorry, I have to correct the command above. I can only make it work by
> using relative path, not absolute path. In another words, I need to be
> at /cygdrive/d/project/bin/ first, then use this command:
> 
> java -classpath "../libs/*;." A.B.C.MainWindow
> 
> The following command does not work and I don't understand why:
> 
> java -classpath "/cygdrive/d/project/libs/*;." A.B.C.MainWindow
> 
> The error message shows that A.B.C.MainWindow was found and loaded,
> however, those JAR files were not found and loaded. I have added root
> "/" to the classpath, and the error is the same:
> 
> java -classpath "/;/cygdrive/d/project/libs/*;." A.B.C.MainWindow

Well, duh.  Did you read the answer upthread for that?  Someone already explained this to you.  You should read the answers that people here generously provide for free at your request.

"java" is a Windows program.  It does not recognize Cygwin paths.  Again we tell you.

You even got a link upthread for the "java" command and how it takes parameters.  You should read the answers that people here generously provide for free at your request.  And the Java documentation.

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Java classpath question and how to run a program from command line? www <xsli2@yahoo.com> - 2011-11-28 13:50 -0800
  Re: Java classpath question and how to run a program from command line? Robert Klemme <shortcutter@googlemail.com> - 2011-11-28 23:08 +0100
  Re: Java classpath question and how to run a program from command line? markspace <-@.> - 2011-11-28 14:21 -0800
  Re: Java classpath question and how to run a program from command line? Lew <lewbloch@gmail.com> - 2011-11-28 15:58 -0800
  Re: Java classpath question and how to run a program from command line? www <xsli2@yahoo.com> - 2011-11-29 06:14 -0800
    Re: Java classpath question and how to run a program from command line? www <xsli2@yahoo.com> - 2011-11-29 06:54 -0800
      Re: Java classpath question and how to run a program from command line? Lew <lewbloch@gmail.com> - 2011-11-29 07:43 -0800
        Re: Java classpath question and how to run a program from command line? www <xsli2@yahoo.com> - 2011-11-29 09:22 -0800
          Re: Java classpath question and how to run a program from command line? Lew <lewbloch@gmail.com> - 2011-11-29 12:08 -0800
  Re: Java classpath question and how to run a program from command line? Roedy Green <see_website@mindprod.com.invalid> - 2011-11-29 13:57 -0800

csiph-web