UiPath Community: Communication Mining from Zero to Hero
Intro to Java 5-8 and Eclipse for FRC Programming
1. Intro to Java 5-8 and Eclipse
11/16/14
Jeanne Boyarsky
Programming Mentor FRC Team 694
Twitter @jeanneboyarsky
Blog: http://www.selikoff.net
Moderator on Java forums at:
http://www.coderanch.com
3. Installing Eclipse
Eclipse Luna 4.4
+ plugins
https://www.eclipse.org/downloads/
Eclipse is used more
“in the real world”
than NetBeans
FIRST recommends C/C++
edition. (I used the Java
edition and things seem fine)
4. Eclipse Version Q&A
Can I use an older version of Eclipse?
It will not support Java 8 syntax additions or
the FRC plugins..
When is Eclipse released?
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)
5. Eclipse - Perspectives
Eclipse has different “perspectives” (sets of views)
- Java and Resource
- Git/Svn and Team Synchronization
6. Eclipse - Views
Views are screen elements
- Package explorer
- Problems
- Tasks – used for code with //TODO
- Console - output
To add:
Window > Show view > Console
8. 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
12. 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
13. Creating a new project
Just like NetBeans, create a new project
14. More Eclipse
Create a class
Force a rebuild
Update the classpath
Look at errors
Sync package explorer with code
Compact list
Outline view
15. Running the Ant script
Right click build.xml - Run As
Or run link up top
Note: Eclipse projects do not build using Ant automatically,
they have a .classpath file for the classpath
16. How to migrate NetBeans project?
There isn't a generic way
I recommend:
– Create a new Eclipse project
– Copy the source code from the
NetBeans source directory
– Commit to version control
17. Installing Java
Java Platform (JDK) 8
Not the micro
edition anymore!
(Or)
http://www.oracle.com/technetwork/java/javase/downloads/i
ndex.html
18. 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.
19. 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)
20. 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)
21. 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
22. Java 5 – Enhanced for loop
Which is easier to read/write?
Can use for array, ArrayList and more
23. Java 5 – Static imports
Don't have to write Ports.X over and over and ...
25. Java 7 - Underscores
Make long numbers easier to read during the rush to
change code between matches:
26. 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);
27. Java 7 – try with resources
Which is easier to read/write?
28. Java 8
Lambdas and functional programming (way too much to
cover in one slide)
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())
29. 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!
30. 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
31. 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/