2

i tried 'java -cp' command line to reference jar files.but for some reasons it doesn't work.FYI,java version on my machine is java1.8.

Later i tried '-Djava-ext-dirs' option and it works. Is there any syntax error in the command?

enter image description here

enter image description here

and my folder hierarchy: enter image description here enter image description here

abracadabra
  • 371
  • 2
  • 16

1 Answers1

1

Edit: The statement You cannot use wildcards in the -cp paths. is outdated. See @Heri's comment below.

You cannot use wildcards in the -cp paths. You have to list all jars separated by ; on Windows or by : on Linux and macOS.

You can create a shell/command script to list the jars in your lib directory and populate the -cp option for you.

Xvolks
  • 2,065
  • 1
  • 21
  • 32
  • 1
    Since java 6 it _is_ possible to use wildcard. See http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/classpath.html – Heri Aug 26 '17 at 13:11
  • @Heri: thank you for letting me know that, I'm too old for this ;) – Xvolks Aug 26 '17 at 13:21
  • solved,problem is i didn't put ; at the end of -cp option. Correct command is: java -cp lib/*; test.A – abracadabra Aug 26 '17 at 13:24