Ask coding questions

← Back to all posts
Jar files
zimtech0 (6)

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.

BrianWillem (6)

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 .
java -classpath .:./jars/

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 .; java Main"

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

tbaier (2)

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

FaisalSarnap (0)

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!!

MOHAMEDSulai (0)

how to add jar file in java?