This article is a sequel to the article below.
[LeJOS] Let's program mindstorm-EV3 in Java [Environment construction first part]
In the second part, we will explain how to build a Java programming development environment using leJOS. Use eclipse for Java integrated development environment. Build the program with eclipse, transfer the generated executable file to EV3 and execute it. By using the eclipse plugin for leJOS, those tasks can be done only on the IDE, which is very convenient.
Download eclipse and install it according to the GUI. https://eclipse.org/downloads/
Let's start it.
Select "Install New Software" from "Help" on the menu bar.
Add repository Set Location to http://www.lejos.org/tools/eclipse/plugin/ev3/ and select OK. Check leJOS Ev3 Support and select Next.
Click OK or Next for the confirmation screen, license agreement screen, and warning screen that will appear after this. (Image omitted)
Select "Preferences" from "Eclipse" on the menu bar. Set the path to the folder where you unzipped leJOS_EV3_0.9.1-beta.tar.gz downloaded in the first part to EV3_HOME. ..
Also, set the IP address of the EV3 main unit.
Select "File"-> "New"-> "Other" from the menu bar. Then select LeJOS EV3 Project and proceed to OK.
Decide on a project name. Here, I chose Ev3Test.
You can see that the project was created correctly by looking at the Package Explorer.
Right-click on the project and select New-> Class. Here, the class name is set to Ev3Test.
Let's make a simple program. Create a program that only displays Hello World on the LCD by referring to the sample code.
Ec3Test.java
import lejos.hardware.BrickFinder;
import lejos.hardware.Keys;
import lejos.hardware.ev3.EV3;
import lejos.hardware.lcd.TextLCD;
public class Ev3Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
lcd.drawString("Hello World", 4, 4);
keys.waitForAnyPress();
}
}
Right-click on the project and select Run as-> LeJOS EV3 Program.
The program is built, transferred to the EV3 main unit, and executed. If successful, the following log will be displayed on the eclipse console.
IP address is /192.168.2.91
Uploading to 192.168.2.91 ...
Program has been uploaded
Running program ...
leJOS EV3 plugin launch complete
Display on the EV3 main unit. Press any button to exit the program.
Now you have an environment for developing EV3 using Java. If you want more information, please check the leJOS site. https://sourceforge.net/projects/lejos/
https://sourceforge.net/p/etroboev3/wiki/lejosev3_mac_eclipse_section06/
Recommended Posts