====== Installing an External Library in BlueJ with an external .jar file ======
- Make a New Project in BlueJ
- Select ''Preferences'' (In MacOS it is under the 'BlueJ' menu,in Windows it is under 'Tools' ){{::tools.png?300|}}
- Click the ''Libraries'' Tab
- Press the ''Add File'' button {{::librry.png}}
- Select the ''kareljrobot.jar'' file or other .jar file you downloaded, press the ''Open'' button
- It will tell you to restart the Virtual Machine, press the ''Okay'' button
- Under the ''Tools'' menu select ''Reset Java Virtual Machine'' (or press **Ctrl-Shift-R**){{::reset.png?400|}} Sometimes it is best to simply Quit and relaunch BlueJ.
- To test the APLU Turtle Library {{ ::jturtle-0.1.1.jar |jturtle-0.1.1.jar}}, try this example program:
import ch.aplu.turtle.*;
import java.awt.Color;
/**
*
* @author (Your Name)
* @version September 0, 2024
*/
public class MyPicture {
public static void main(String[] args) {
Turtle hexter = new Turtle(Color.GREEN);
hexter.setPos(100,-50);
for (int i=0; i< 6; i++) {
hexter.forward(100);
hexter.right(-60);
}
hexter.setPos(0,0);
hexter.setFillColor(Color.BLUE);
hexter.fill();
Turtle t = new Turtle(hexter);
t.setColor(Color.RED);
t.setPos(-200, 180);
t.hideTurtle().label( "by My name");
}
}
- To test our the ''kareljrobot.jar''installation, make a new class ''RobotRunner'' to test it out:
import kareltherobot.*;
public class RobotRunner implements Directions
{
public static void main(String[] args)
{
World.setDelay(150);
World.placeBeepers(4, 3, 2);
World.setVisible();
}
}