Ramon F Herrera wrote:
> I always do most of my development inside an IDE (Eclipse or NetBeans)
> but lately I have been experimenting with the "Command Prompt" on
> WinXP. I am under the impression -which I would obviously like to
> corroborate- that commands such these don't work at all:
> C:\> set CLASSPATH=C:\somedir\mylib.jar
> C:\> java -jar myprogram.jar
CLASSPATH will be ignored here.
> C:\> java -classpath C:\somedir\mylib.jar -jar myprogram.jar
> Should this one work at all?
No, in the sense that the -classpath option will be ignored.
> C:\> java -DMain-Class=playground.Salutations -jar helloworld.jar
Main-Class isn't a command-line property.
> I have had very little success settings things up from the command
> line, but all my tests run well when I place things (Main-Class and
> Class-Path) in the Manifest.
Which is the documented behavior.
> How is the verbose mode used? Is there any way to obtain essential
> info such as the Main Class and the classpath?
Yes, look at the manifest of the JAR. I don't know how "verbose mode" affects
visibility of these parameters.
> Execute a program encapsulated in a JAR file.
> The first argument is the name of a JAR file instead of a startup class name.
> In order for this option to work, the manifest of the JAR file must contain
> a line of the form Main-Class: classname.
Note the word "must" here.
> When you use this option, the JAR file is the source of all user classes,
> and other user class path settings are ignored.