-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No clear what is "repository" of algs4 #18
Comments
OK, so I think I figured this out. If I want to include algs4.jar in your own Maven project, this is what you do (assuming you have Maven installed):
Add the following to your project's pom.xml : <dependency>
<groupId>edu.princeton.cs</groupId>
<artifactId>algs4</artifactId>
<version>1.0.0</version>
</dependency> and that seems do it. As for the Maven Central Repository that didn't seem to work for me at all, and I suspect even if it did, the resulting I think the algs4.jar from the book site didn't work maybe because of version info? But when you build your own with this repo, you can see what you're getting. |
The Maven and Gradle info was created by Peter Korgan. I don’t use Maven, so can’t provide much more information.
https://github.com/kevin-wayne/algs4/blob/master/README-MAVEN.txt
https://github.com/kevin-wayne/algs4/blob/master/pom.xml
There is also a bintray link
https://bintray.com/algs4/maven/algs4
If the instructions are unclear, feel free to suggest improvements.
On Jan 1, 2017, at 7:13 PM, Dmitri Brengauz ***@***.***> wrote:
I am trying to work work through the Coursera class. In my pom.xml file I have
<dependency
>
<
groupId>com.googlecode.princeton-java-algorithms</groupId
>
<
artifactId>algorithms</artifactId
>
<
version>4.0.1</version
>
<
dependency>
in my code, I have a simple import statement:
import edu.princeton.cs.algs4.StdOut;
this does not work with maven!
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project algorithms: Compilation failure: Compilation failure:
[ERROR] $HOME/algorithms/src/main/java/org/momus/algorithms/HelloWorld.java:[8,30] package edu.princeton.cs.algs4 does not exist
[ERROR] $HOME/algorithms/src/main/java/org/momus/algorithms/HelloWorld.java:[13,9] cannot find symbol
[ERROR] symbol: variable StdOut
[ERROR] location: class org.momus.algorithms.HelloWorld
Running mvn dependency:resolve shows that it is installed:
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building algorithms 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:resolve (default-cli) @ algorithms ---
[INFO]
[INFO] The following files have been resolved:
[INFO] junit:junit:jar:3.8.1:test
[INFO] java3d:j3d-core:jar:1.3.1:compile
[INFO] com.googlecode.princeton-java-algorithms:algorithms:jar:4.0.1:compile
[INFO] java3d:vecmath:jar:1.3.1:compile
[INFO] java3d:j3d-core-utils:jar:1.3.1:compile
[INFO] gov.nist.math:jama:jar:1.0.3:compile
[INFO] com.googlecode.princeton-java-introduction:stdlib:jar:1.0.1:compile
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.066 s
[INFO] Finished at: 2017-01-01T17:03:12-07:00
[INFO] Final Memory: 13M/300M
[INFO] --------------------------------
So tried importing it with import com.googlecode.princeton-java-algorithms.algorithms.StdOut; and various permutations of this line.
That fails with
[ERROR] $HOME/algorithms/src/main/java/org/momus/algorithms/HelloWorld.java:[8,32] ';' expected
[ERROR] -> [Help 1]
What do I have to do to use algs4 with Maven?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Kevin Wayne
Phillip Y. Goldman '86 Senior Lecturer
Department of Computer Science
Princeton University
|
Currently there is a <dependency>
<groupId>edu.princeton.cs</groupId>
<artifactId>algs4</artifactId>
<version>1.0.3</version>
</dependency> From the version number and last update time it seems apparently not done by Princeton but others. The sources there is not synchronized to the latest here, so those who want to use it should keep this in mind - take risk on your own. |
@Momus I don't think it needs that many steps, after clone the repository you just need to execute git clone https://github.com/kevin-wayne/algs4 && mvn clean install Then add below to your <dependency>
<groupId>edu.princeton.cs</groupId>
<artifactId>algs4</artifactId>
<version>1.0.0.0</version>
</dependency> |
The solution above worked for me 👌. EDIT: Actually, I needed to |
@ny83427 very nice ! |
Hello,
What is the Maven dependency and what is the repository we should to use to build application using Maven?
Could you please provide the appropriate entries we can use in pom.xml in the project?
Best regards
Powazny
The text was updated successfully, but these errors were encountered: