Skip to content
← Back to Community
Jar files
Profile icon
zimtech0

Is it possible to include jar files in project classpath directory? Have a class project I would like to import along with classes contained in jar files.

Let me know thanks.

Voters
Profile icon
BRANDONANGOS1
Profile icon
Levy_Chevy
Profile icon
OscarJGPrice
Profile icon
MarkZiminsky
Profile icon
MtNetworkJPMt
Profile icon
michael_remington
Profile icon
WilliamJeggo
Profile icon
Bobster_61
Profile icon
noam2092005
Profile icon
DavidShen2
Comments
hotnewtop
Profile icon
BrianWillem

Jar files can be uploaded to your project the same as other files. I put my jar files into a "jars" folder that I create in my repl.

From that point, you can compile and run your code from the command line:
javac -classpath .:./jars/* -d . Main.java
java -classpath .:./jars/* Main

If you want to configure the "Run" action, you can define a .replit file in your project and add the following line.
run = "export CLASSPATH=".:./jars/*"; javac -d . Main.java; java Main"

Configure these commands to match your environment, class names, etc.

Profile icon
tbaier

@BrianWillem Thank you so much for this, it was very helpful!

Profile icon
FaisalSarnap

@BrianWillem
Hi there. Apologies as I am still new to REPL as well as Java. I have a .jar file from the school that deals with a window pop up and I want to use it for my assignment. How do I add that into my repl project? Again, sorry, novice here. Thanks much!!

Profile icon
MOHAMEDSulai

how to add jar file in java?