I\'ve started Coursera Algorythms course. Practice assignments must be done on Java and they suggest using DrJava as IDE, but it\'s really unconvenient. So I\'d like to use
It is probably because there is no package structure in the libraries, so you can't import classes from it. This might help you, How to use classes in Referenced Libraries in Eclipse.
Incase of Gradle, add the maven repository entry in repositories section of build.gradle as follows:
repositories {
mavenCentral()
maven {
url 'https://dl.bintray.com/algs4/maven/'
}
}
Add the dependency as follows:
compile group: 'edu.princeton.cs', name: 'algs4', version: '1.0.4'
In case of Maven, add the entry in repositories tag in build.xml, as follows:
<repositories>
<repository>
<id>org.coursera.algs4</id>
<name>Algs4 lib</name>
<url>https://dl.bintray.com/algs4/maven/</url>
</repository>
</repositories>
Add the dependency as follows:
<dependencies>
<dependency>
<groupId>edu.princeton.cs</groupId>
<artifactId>algs4</artifactId>
<version>1.0.4</version>
</dependency>
</dependencies>
One option is that there is a maven repo on github provided by slok. The bad part of this is the jars added were those using the default package, so you can't use a package structure.
UPDATE: I have added the package versions of the jar to the repo and created a pull request it has now been accepted.
Note that I have changed the identifiers to match the original package structure from Princeton.
<dependencies>
<dependency>
<groupId>edu.princeton.cs.introcs</groupId>
<artifactId>algs4-package</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>edu.princeton.cs.introcs</groupId>
<artifactId>stdlib-package</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>org.coursera.algs4</id>
<name>Algs4 coursera course custom repository</name>
<url>https://raw.github.com/slok/algs4-mvn-repo/master</url>
</repository>
</repositories>
Follow the below steps
Right click on your project > Properties. It will open the following window
Select "Java Build Path" from the left side. Now select "Libraries" tab from the right side
Click on "Add External Jars"
Add the Jar files.
Now you are done