Saturday, July 1, 2023

Adding jar files to a Java Project on the Command Line using Classpath

This is a simple post about how you can add jar files on the command line so that you can incorporate their contents in your own projects. This can be handy if you only want to test a third party library and not work with an IDE.

The idea is that if you want to use a third party library which is contained in a jar-file, what you simply do is that you use the -classpath option in your compile command:

javac -classpath ".:sqlite-jdbc-3.39.3.0.jar" TestClass.java

Where sqlite-jdbc-3.39.3.0.jar is the third party library jar file which you have downloaded. In this case SQLite.

What you must do next is to use the same -classpath option in your run-command:

java -classpath ".:sqlite-jdbc-3.39.3.0.jar" TestClass.java

You can watch an example of this in the video below.



No comments:

Post a Comment

A Rapid Review on Website Accessibility

I hereby present to you a rapid review on accessibility in development of websites, with the title:  Automated Testing for Website Accessibi...