GuruKulki
GuruKulki

Reputation: 26428

How to include a classpath from a file?

I have extracted the classpath entries in a file cp.txt using the maven build-classpath command. but now I am not sure how to run the java class using the classpath entries from the cp.txt file. Any help would appreciated.

Thanks.

Upvotes: 2

Views: 204

Answers (1)

Adam Siemion
Adam Siemion

Reputation: 16039

It is not possible to provide a file with classpath entries. Class path entires location has to be provided as a -cp or -classpath argument to java or the CLASSPATH environmental variable.

However you can use your shell to put the content a file into an argument,

  • Unix:

    java -cp "`cat cp.txt`" ...
    
  • Windows

    set /p classpath=<cp.txt
    java -cp %classpath% ...
    

Upvotes: 3

Related Questions