Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing an external java package

Tags:

java

package

I am new to java, and I am trying to build a project that has an external dependency. When I try to build it

[javac] Compiling 814 source files to ~/Desktop/Dev/bitcoinj/out
[javac] ~/Desktop/Dev/bitcoinj/src/com/google/bitcoin/core/Block.java:25: package org.slf4j does not exist
[javac] import org.slf4j.Logger;
[javac] ...

How can install the missing external package? Is there a java package manager similar to the python pip?

like image 968
D R Avatar asked May 03 '11 01:05

D R


People also ask

Can we import package in Java?

Java has an import statement that allows you to import an entire package (as in earlier examples), or use only certain classes and interfaces defined in the package. The import statement is optional in Java.

Does Java have a package manager?

Java has two main options for package management, Maven is the industry standard. Maven Central Repository is an online repository containing a vast array of packages available for use in your projects.

Where are Java libraries stored?

class files, they're in lib\rt. jar in the JRE directory ( . jar is the same as . zip , so you can open it with anything that can open zip files).


2 Answers

You could use maven which would do the dependency handling and building for you.

Dependency management is a core feature of Maven. Managing dependencies for a single project is easy. Managing dependencies for multi-module projects and applications that consist of hundreds of modules is possible. Maven helps a great deal in defining, creating, and maintaining reproducible builds with well-defined classpaths and library versions.

like image 171
papanito Avatar answered Nov 02 '22 12:11

papanito


There's not a package manager that I know of. You're going to have to manually download the jar file -- in this case, its from http://www.slf4j.org/ . After that, you can either do as Dennis says, or add the jar file explicitly to your classpath.

like image 23
Kal Avatar answered Nov 02 '22 12:11

Kal