User Tools

Site Tools


how_to_install_the_library_in_bluej

Installing an External Library in BlueJ with an external .jar file

  1. Make a New Project in BlueJ
  2. Select Preferences (In MacOS it is under the 'BlueJ' menu,in Windows it is under 'Tools' )
  3. Click the Libraries Tab
  4. Press the Add File button
  5. Select the kareljrobot.jar file or other .jar file you downloaded, press the Open button
  6. It will tell you to restart the Virtual Machine, press the Okay button
  7. Under the Tools menu select Reset Java Virtual Machine (or press Ctrl-Shift-R) Sometimes it is best to simply Quit and relaunch BlueJ.
  8. To test the APLU Turtle Library 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"); 	
     
    	}
     
    }
  9. To test our the kareljrobot.jarinstallation, 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();
    	}
      }
how_to_install_the_library_in_bluej.txt · Last modified: 2024/09/10 09:04 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki