To download eclipse First, I chose the Eclipse IDE for Java Developers64 bit version, download it and unzip it to your favorite location and double-click Eclipse.exe to start
Then start the new project, File-and new Java project, with the project name casually written, as
Right-click the src folder, Add-New Java class, here you need to note that the Name column is the class name, I wrote TESTALGS4, in order to test the "algorithm fourth version" of the test given by the author of the sample
The code is as follows:
Import Edu.princeton.cs.algs4.StdDraw;Public Class TestAlgs4 {Public Static void Main(String[]Args){Stddraw.Setscale(-1,1);Stddraw.Clear(Stddraw.BLACK);Stddraw.Setpencolor(Stddraw.White);Stddraw.Square(0,0,1);Write some text Stddraw.Setpencolor(Stddraw.White);Stddraw.Text(0,+0.95,"Hello, world! This is a test for Java program. ");Stddraw.Text(0,-0.95,"Close This window to finish the installation.");Draw the Bullseye Stddraw.Setpencolor(Stddraw.Book_blue);Stddraw.Filledcircle(0,0,0.9);Stddraw.Setpencolor(Stddraw.BLACK);Stddraw.Filledcircle(0,0,0.8);Stddraw.Setpencolor(Stddraw.Book_blue);Stddraw.Filledcircle(0,0,0.7);Stddraw.Setpencolor(Stddraw.BLACK);Stddraw.Filledcircle(0,00.6 ); //draw a picture of the textbook Stddraw. (000.65 0.80 ); } /span>
At this point eclipse should be a lot of error, do not worry, add a reference to the textbook library Algs4.jar:
Right-click Project name (I am HelloWorld), Properties, Java Build Path, Libraries, Add extenernal JARs, select C:\Users\username \algs4\algs4.jar can,
Click OK to exit, the error message disappears, the compilation run can see the same results as the installation of Algs4.exe:
Transfer from http://shuxiao.wang/2016/04/21/algs4-Eclipse.html
The fourth version of the algorithm calls the ALGS4 library in eclipse