FRC (FIRST Robotics Challenge) is switching from Java ME 1.4 to Java SE 8 along with switching from NetBeans to Eclipse for the 2014-2015 school year. I gave this presentation to representatives from teams 2601 (Townsend Harris) and 694 (Stuyvesant) today.
Team 2601 recorded my presentation which is available on youtube (https://www.youtube.com/watch?v=AgreKkRjFgU&feature=youtu.be) and at the end of my presentation on slideshare.
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
1. Intro to Java 5-8 and Eclipse
6/8/14
Jeanne Boyarsky
Programming Mentor FRC Team 694
Twitter @jeanneboyarsky
Blog: http://www.selikoff.net
Moderator on Java forums at:
http://www.coderanch.com
2. Java – “New” Features
This presentation is not a complete list.
Features most likely needed for FRC programming.
Includes:
– Non-micro APIs from Java 1.4 (and below)
– Java 5 new features
– Java 7 new features
– Java 8 new features
– (Java 6 didn't have much)
3. Java 1.4 non-Micro APIs
java.util.ArrayList – like an array, but grows dynamically
(faster than a Vector)
java.lang.Math – more methods
java.util.Properties – read file in format key=value
(example in Java 7 section)
4. Java 5 – Generics/Autoboxing
Generics – you specify the type of the ArrayList and the
compiler tells you if you use it wrong
Autoboxing – Java converts primitives (int, double, etc) to
Objects and back for you
5. Java 5 – Enhanced for loop
Which is easier to read/write?
Can use for array, ArrayList and more
6. Java 5 – Static imports
Don't have to write Ports.X over and over and ...
8. Java 7 - Underscores
Make long numbers easier to read during the rush to
change code between matches:
9. Java 7 – Reading a file
NIO.2 makes reading a file (or network connection or the
like) easier.
Also, now that we are on Java Standard Edition you
can use open source APIs such as
http://commons.apache.org/proper/commons-io/
Which lets you code:
String s = FileUtils.readFileToString(file);
10. Java 7 – try with resources
Which is easier to read/write?
11. Java 8
Lambdas and functional programming (way too much to
cover in one slide)
Will likely not work with FRC APIs at least in 2015
Consider whether you want to use this style of
programming when training your new team members.
Like Groovy – might be less clear at first.
Examples:
new Thread(() -> System.out.println(“foo”))
words.sort ((a,b) -> a.length() – b.length())
12. Multi-threading
Remember we have 2 CPUs now.
What can the second one do?
– Vision
– Logging
– Long running calculations
– Poll a sensor until some event happens
– Use your imagination!
13. Installing Java
Java Platform (JDK) 8
http://www.oracle.com/technetwork/java/javase/downloads/i
ndex.html
(Or)
Not the micro
edition anymore!
14. Java Version Q&A
Why doesn't Java know how to count? The
versions go 1.1, 1.2, 1.3, 1.4, 5, 6, 7, 8
Blame marketing!
What's the difference between Java Micro
Edition (used by FRC until 2014) and the
“small memory” version (used by FRC starting
in 2015)?
Java Micro Edition didn't have a lot of the built in
Java functions that you can now use.
15. Installing Eclipse
Eclipse Luna 4.4
https://www.eclipse.org/downloads/ (after 6/25/14)
https://www.eclipse.org/downloads/index-developer.php
(release candidate if trying before 6/25/14)
Eclipse is used more
“in the real world”
than NetBeans
Either the Eclipse Standard or
Eclipse IDE for Java
Developers is ok.
Standard uses less memory
and has everything we need
for FIRST
16. Eclipse Version Q&A
Can I use an older version of Eclipse?
Yes, but it will not support Java 8 syntax
additions.
What happens on 6/25/14?
Eclipse releases come out on the fourth
Wednesday of June.
Release Name Version Java supported
June 2012 Juno 4.2 Java 6 (also known as 1.6)
June 2013 Kepler 4.3 Java 7 (also known as 1.7)
June 2014 Luna 4.4 Java 8 (also known as 1.8)
17. Eclipse - Perspectives
Eclipse has different “perspectives” (sets of views)
Java and Resource
Git/Svn and Team Synchronization
FRC? (don't know if will be in 2015 plugin)
18. Eclipse - Views
Views are screen elements
Package explorer
Problems
Tasks – used for code with //TODO
Console - output
To add:
Window > Show view > Console
20. Tip: Save launch configuration
Run as > ___ …. lets you enter options
On common tab can save those options
Can even put them in SVN/Git because just a file
21. Tip: Variables
Use a classpath variable for the FRC libraries so no
changes to project on different computers
23. Warnings about FRC Eclipse plugin
This is NOT the official plugin we will use in the 2014-
2015 season.
It is the experimental version from 2011.
I don't recommend installing it; this is just to get an idea of
the process
24. Installing the FRC Eclipse Plugin
Help > Install New Software
Enter URL http://first.wpi.edu/FRC/java/eclipse/update/
Click add button
Give it a name. I used “FRC-old” so I remember to
uninstall it before the season starts.
Check FRC box
Click next/accept license/next/finish. Restart Eclipse when
finishes download (This step uses the internet to
download the plugin)
25.
26. Configuring FRC Eclipse Plugin
Enter your team number in Eclipse global preferences
Windows > Preferences on Windows/Linux
Eclipse > Preferences on Mac
Note difference between global and project
preferences
27. Creating a new project
Just like NetBeans, create a new project
28. Creating a new component
Right click where you want to add something
29. Running the Ant script
Run As > FRC …
Note: Eclipse projects do not build using Ant automatically,
they have a .classpath file for the classpath
30. How to migrate NetBeans project?
There isn't a generic way
I recommend:
– Create a new Eclipse FRC project
– Copy the source code from the
NetBeans source directory
31. Questions
About Java or Eclipse:
– Friendly forums for those new (or not
new) to Java
– http://www.coderanch.com
For FRC specific questions:
– After the 2014-2015 plugins launch
– http://www.chiefdelphi.com
32. References
Blog posts from Championships:
http://www.selikoff.net/2014/04/25/first-wpilib-in-2015/
How to get around the problem launching
Eclipse on a Mac:
http://www.selikoff.net/2013/06/29/eclipse-kepler-4-3-mac/
Old plugin docs:
https://subversion.assembla.com/svn/blue-
cheese/branches/2012/docs/Tutorials/FRCEclipsePluginS
etup.pdf