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

1
  • solved,problem is i didn't put <italic>;</italic> at the end of -cp option.Correct command is:<strong> java -cp lib/*; test.A</strong> Commented Aug 26, 2017 at 13:21

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Since java 6 it is possible to use wildcard. See docs.oracle.com/javase/6/docs/technotes/tools/solaris/…
@Heri: thank you for letting me know that, I'm too old for this ;)
solved,problem is i didn't put <italic>;</italic> at the end of -cp option. Correct command is:<strong> java -cp lib/*; test.A</strong>

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.