算法第四版 在Linux 中调用Algs4库
一: 搭建Java 环境 :
确认版本: 1.8及以上
[username:~/] javac -version javac 1.8.0_111
[username:~/] java -version java version "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
二
- 建立目录 /usr/local/algs4.
[username:~/] cd /usr/local [username:/usr/local] sudo mkdir algs4 [username:/usr/local] sudo chmod 755 algs4
[username:/usr/local] cd algs4 [username:/usr/local/algs4] pwd /usr/local/algs4
- 下载 algs4.jar (包括了javac-algs4 和java-algs4).
[username:/usr/local/algs4] sudo wget http://algs4.cs.princeton.edu/code/algs4.jar [username:/usr/local/algs4] sudo wget http://algs4.cs.princeton.edu/linux/javac-algs4 [username:/usr/local/algs4] sudo wget http://algs4.cs.princeton.edu/linux/java-algs4 [username:/usr/local/algs4] sudo chmod 755 javac-algs4 java-algs4 [username:/usr/local/algs4] sudo mv javac-algs4 /usr/local/bin [username:/usr/local/algs4] sudo mv java-algs4 /usr/local/bin
- 检查是否安装成功
machine:~/hello username$ java-algs4 edu.princeton.cs.algs4.StdDraw [ displays a graphics window with some geometric shapes and text ] machine:~/hello username$ java-algs4 edu.princeton.cs.algs4.StdAudio [ plays an A major scale ]
参考:
http://algs4.cs.princeton.edu/linux/