Compiling multiple jar and java files with javac
I have downloaded a sample code written in java which has multiple jar and java files. I am not a Java programmer, so it is difficult for me to compile the code. Here's my attempt:
javac -classpath lib/*.jar src/*.java
However, this is what I get:
javac: invalid flag: lib/dom4j-1.6.1.jar
Usage: javac <options> <source files>
use -help for a list of possible options
What's wrong with my approach and how can I compile the code? ALl jar files are in lib folder and java files in src folder.
source to share
You need to stop the globbing
wild-card wrapper by lib/*.jar
executing it.
Also, you need to remove the suffix .jar
... because that works with classpath templates; see Oracle Classpath Setting .
So...
javac -classpath lib/\* src/*.java
Using an IDE is another option. However, if all you want to do is compile and run, then downloading, installing and learning to use the IDE is overkill (IMO). And the downside is that it's helpful for a Java programmer with an IDE to also understand how to compile and run from the command line ...
source to share