简体   繁体   English

如何在Java Eclipse中导入/使用StdDraw?

[英]How can I import / use StdDraw in java eclipse?

I have found 3 questions similar to mine and none of them helped me at all (some of them even had some down votes, the answers I mean). 我发现了3个与我的问题类似的问题,但没有一个问题对我有任何帮助(其中一些问题甚至是我的意思是反对)。

I wanted do an old homework for learning purposes and it's saying that we can use StdDraw function of java. 我想做一个老作业,以供学习之用,也就是说我们可以使用Java的StdDraw函数。 (What we are supposed to do by the way is drawing the pythagoras-tree!) (我们应该做的是绘制毕达哥拉斯树!)

But I haven't found a way to import that in java, either it was outdated or it was explained very complicated. 但是我还没有找到在Java中导入它的方法,它已经过时,或者解释得很复杂。 : / :/

"StdDraw" is not part of the Sun/Oracle Java distribution (and never was), which is why you're unable to import it. “ StdDraw”不是Sun / Oracle Java发行版的一部分(而且从来没有),这就是为什么您无法导入它。 I'm guessing that you're referring to a Java class that was developed at Princeton University for educational purposes as part of their stdlib.jar library: 我猜想您是指普林斯顿大学为教育目的而开发的Java类,作为其stdlib.jar库的一部分:

http://introcs.cs.princeton.edu/java/stdlib/ http://introcs.cs.princeton.edu/java/stdlib/

Download that jar to your computer. 将该罐子下载到您的计算机。 Assuming that you've already created a project in Eclipse: 假设您已经在Eclipse中创建了一个项目:

  1. Right click "Project" and select "Properties" 右键单击“项目”,然后选择“属性”
  2. Select "Java Build Path" 选择“ Java构建路径”
  3. Select "Libraries" tab 选择“库”标签
  4. Click "Add external JARs..." and select the jar you just downloaded 单击“添加外部JAR ...”,然后选择刚下载的jar。

You should now be able to import StdDraw into your app. 现在,您应该能够将StdDraw导入到您的应用程序中。

1) Right click on (default package) 1)右键单击(默认程序包)

2) Build path, configure build path 2)构建路径,配置构建路径

3) libraries tab 3)库选项卡

4) Click on Class path 4)点击课程路径

5) Add External JARS. 5)添加外部JARS。

This worked for me. 这对我有用。 Other people might say to click on "Add external class folder" if this doesn't work click "add external jars". 如果这不起作用,其他人可能会说单击“添加外部类文件夹”,然后单击“添加外部jar”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM