1

I have a java file with jar dependencies an I would like to compile them using command in command prompt from windows PC. I have placed all 3 jar files and java file in same folder of D drive. Do i need to set class path in environmental variables? my jar file names are juh-4.1.2.jar, ridl-4.1.3.jar and unoil-4.1.2.jar?

Any help will be greatly appreciated. Thanks in advance

nitesh
  • 11
  • 3
  • 1
    You *could* set the `CLASSPATH` variable, but I suggest you specify the `-cp` parameter to your `javac` invocation instead. If they are all in the same directory it can be as simple as `javac -cp D:\Path\To\The\Directory\* TheFilesYouWantToCompile.java`. – Joachim Sauer Oct 28 '21 at 10:11
  • D:\JavaRates_eclipse>javac -cp D:\JavaRates_eclipse\* fileaname.java javac: file not found: OOConnnection.java Usage: javac use -help for a list of possible options, I get above error saying file not found – nitesh Oct 28 '21 at 15:35

1 Answers1

1

You should only need to javac the input files and pass the -cp flag

Command should look something like

C:\Path\To\JDK\javac.exe -cp "D:\pathtojar1.jar; D: [... ]" *.java

EDIT: Use CP Flag, didn't see you had external .jar dependencies

clockw0rk
  • 576
  • 5
  • 26