Editor: IntelliJ CE
What I want: Be able to write
setCanvas(500,500);
Instead of
StdDraw.setcanvas(500,500);
Problem: I can't figure out how to correctly import the Stddraw library. If i simply do
import StdDraw;
IntelliJ tells me "StdDraw" symbol cannot be resolved. If I comment it out I can call methods from StdDraw but I have to write StdDraw.setcanvas(500,500);
StdDraw.java is in the same directory as Solver.java.
Code:
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
// import StdDraw;//StdDraw is in the same directory as Solver
public class Solver {
public static void main(String[] args) {
System.out.println("Solver main is running.");
StdDraw.setCanvasSize(500, 500);
StdDraw.setPenColor(StdDraw.RED);
StdDraw.filledRectangle(0,0,10,10);
}
}
I've already tried: - Making sure Stddraw.java is in the same directory as the file I'm compiling and running - Looking at http://introcs.cs.princeton.edu/java/stdlib/javadoc/StdDraw.html - Searching for COMPLETE code examples, ie. code that shows how to import the library - Searching YouTube tutorials - Reading https://www.jetbrains.com/idea/help/library.html - Fiddling around with adding stuff in front of StdDraw, eg. stblib.StdDraw
You need to add Stdlib to your local libraries of your java project. StdDraw is part of this Stdlib library.
Now you can use the StdDraw class. You don't need to import the class at the top of the file.