How do I import a. jar file without using an IDE? (Java)

Asked

Viewed 123 times

-4

Ex: I have a. jar file that I need to import in order to access the api, how do I do it right in the code? I don’t know if I was specific, but how? (No IDE)

1 answer

2

You can pass some parameters at build time:

javac -classpath lib/bar.jar com/example/Foo.java

In this scenario, your class Foo.java depends on the jar bar.jar.

If you’re using a project that doesn’t use any dependency manager, it gets really complicated to work with.

I recommend taking a look at Maven or in the Gradle. They make it easier when you have external dependencies on the project.

  • In addition to compiling, only running =D was missing

Browser other questions tagged

You are not signed in. Login or sign up in order to post.