For Coders - Development Tools
On This Page
STEP 1: Install the Java Development Kit
STEP 2: Install VS Code and create a sample Java project
STEP 3: Install the WPILib extensions
STEP 4: Install and configure a GitHub connector
NOTE: To run the Driver Station, install the NI Tools and Driver Station
STEP 1: Install the Java Development Kit and Maven
Install the Java Development Kit
It is possible that this step will not be required as of the Jan 2019 release. There hints that the WPILib team will include a Java JDK as part of the official release, but as of the Alpha release (Oct 2018) a Java JDK is required in order compile projects. Certainly, if you want to code in the pre-season to learn java and the FRC libraries, you need to install a JDK. We recommend the OpenJDK
- download latest open source Java 11 JDK from the java.net site. This is a .zip file, and can be unzipped in any directory. The recommendation is to unzip the file into:
- c:\Program Files\Java
- The zipped file contains version of the JDK as the top level of the zip, so the final extact location will be:
- C:\Program Files\Java\jdk-11.0.1
Set the JAVA_HOME environment variable
In Windows, open the File Explorer and right click This PC and select Properties
- Select Advanced system settings (see above)
- Select Environment Variables
Add the User Variable JAVA_HOME (using the New... button) and set the User Variable to the directory where the JDK was unzipped
Maven is required to open a new Java Project in VS Code. This would be useful for practicing Java coding in the pre-season. Teams may want to get used to the VS Code environment before the start of the season.
Since the FRC code uses Gradle instead of Maven, this step is not technically required if teams are only intending to compile only the FRC WPILib code.
Download the 'binary zip' (for example apache-maven-3.6.0-bin.zip) and unzip into into:
- C:\Program Files\Maven
Add the Maven binary folder to the System Path
Open the Environment Variables Menu (similar to the instructions above):
- Open File Explorer
- Right click This PC and select Properties
- Select Advanced system settings
- Select Environment Variables
From the Environment Variables dialog, edit the PATH in the System Variables (second section of the dialog below the Environment Variables):
- Find the variable named Path, and select the item in the list
- Select Edit...
- Add a new Path entry at the bottom pointing to bin directory in the Maven directory where the download was unzipped (recommended C:\Program Files\Maven\(...version...)\bin)
Check your Maven and Java install
Open a command dialog by clicking in the search box in the Taskbar in Windows and typing "cmd" in the search (where Cortana would appear)
- type: mvn -v
- if the JDK and Maven are installed correctly, the output should be something like the image to the left, if not, then either Java or Maven are not installed correctly.
STEP 2: Install Visual Studio Code and create a sample project
Download and install VS Code
Visual Studio Code will replace eclipse as the supported development environment for the 2019 robot season. Visual Studio Code has no built in language support for Java, nor any built in support for GitHub. There are connectors to allow for a Git commit within VS Code, but the push and pull to the repository requires external tooling.
Download and Extract VS Code
- Use the download button to the left to get VSCode
- Install VS Code to any directory. Recommended directory is a new directory under the user, or C:\FRC.
Install the Java Extension Pack in VS Code
To install the Java Extension Pack:
- open VS Code
- click on the Extensions icon in the left side control bar or Ctrl+Shift+X
- type in "Java Extension Pack" in the Search Extensions in Marketspace bar at the top of the Extensions window
- click Install on the "Microsoft Java Extension Pack" - this will install a total of 5 extensions
- click "Reload to Activate" in the Java Extension Pack window on the right once the installation is complete.
Create a sample Java Project to Verify your install
NOTE: Your first sample project will download any required Maven artifacts. You will need an internet connection. This will only happen the first time you use Maven.
- open VS Code
- select View -> Command Pallet... (ctrl-shift-P) to open the Command Pallet
- search for "Maven"
- select "Maven: Generate from Maven Archetype" and select "archetype-quickstart-jdk8
- select the folder where you would like the new project - this should be an empty folder.
A Terminal Dialog will then start in VS Code and any required Maven artifacts will be downloaded. The Terminal session will ask the following prompts
- Define value for property 'groupId': respond with a lower case java package name (eg myPackage)
- Define value for property 'artifactId': respond with the upper case project name (eg MyProject)
- Define value for property 'version' 1.0-SNAPSHOT: : hit enter to keep the default value
- Define value for property 'package' myPackage: : hit enter to keep the default value
The Terminal dialog will then repeat the above options. Hit enter to proceed.
Upon completion, the system will NOT open the created project.
- Use File-> Open Folder... to open the created project.
- The project will build and the progress can be seen in the blue status bar at the bottom. Once the project is built:
- In the Explorer, open main->java->myPackage->App.java
- After the build is complete, the main method can be run using the run button that appears above the method (see below). The class will print "Hello World!" in the Debug Console.
Disable collection of Data (Optional)
If you want to disable the collection of usage data by Microsoft:
- Open File -> Preferences -> Settings
- Search for "telemetry"
- Disable the checkboxes that allow telemetry (usage) data to be sent to Microsoft
STEP 3: Install the WPILib Extensions
Install the WPILib Tools
- download the WPI Extension .vsix file from the WPILib site. Do NOT download a BETA version. Version v2019.0.0-alpha-4 is the public release as of Oct 2018. Download the .vsix file.
- install the WPILib extension pack from the extensions menu by:
- clicking on the ... (three dots in the Extension banner)
- select Install from VSIX... option to load the .vsix file
- reload VS Code (if the re-load prompt does not work, you will need to close and re-start VS code manually).
Create a sample project
Create a sample project by:
- clicking the wpilib icon in the banner upper right. This will open a WPILib menu.
- select WPILib: Create a new project
- use the dialog menu to create a new project:
- select: example, template, Command Based Robot, and enter a directory, project name, and team number and click Generate.
- A pop-up will ask whether to open the project in the current window or a new window. Choose Current Window.
- compile the project by right clicking on the build.gradle component in the project explorer, and select Build Robot Code. This will build the new project and install gradle and all other required components. This will take a few minutes the first time a gradle project is built as additional components are downloaded!
- NOTE: Some Toronto District School Board (TDSB) teams may not be able to compile the first project due to Gradle dependencies being blocked by the TDSB network.
- the build can be deployed to a connected robot using build.gradle menu item "Deploy Robot Code".
NOTE: There is also and import tool to Import an eclipse project into VS Code.
NOTE: Additional VS Code settings are included in the GyroDrive project and can be set after the GyroDrive has been downloaded
Configure VS Code to AutoSave before a Robot Deploy
- open VS Code
- in the banner, click on the WPILib icon
- select WPILib: Set Auto Save On Deploy
- a pop-up will be displayed at the bottom of the VS Code Window:
- select Yes for Automatically Save On Deploy?
- select Globally for Save globally or project level?
STEP 2: Install and configure a GitHub connector
What is GitHub and why should I use it?
GitHub is an open, cloud based Git platform used for storing and synchronizing code among a group of developers. It is highly recommended that FRC teams use GitHub. An external backup of your code can save many heartaches, and it is always useful to be able to return to the last working version of the code for testing purposes. Do not keep the only working version of your code on the C: drive of someone's laptop (or on the driverstation - these can get dropped)! To use GitHub, create a GitHub account.
Git Tools are required to push and pull code from GitHub since this functionality is not built into VS Code. There are many possible GitHub integration tools that can be explored in the VS Code Marketplace (Ctrl+Shift+X), or external tools can be used.
TorontoCodingCollective recommends installing GitHub Desktop to allow committing of code within VS Code, and for a better user experience, GitKraken which is a graphical tool for viewing and managing branches, and for managing push/pull actions to GitHub.
Install GitHub Desktop and configure VS Code for Git
Download and install GitHub Desktop and then configure VS Code to use the Git installation. Click the button on the right to download and install GitHub Desktop. To configure VS Code:
- Open VS Code
- Choose File -> Preferences -> Settings
- Choose the User Settings tab
- Search for "Git: Path"
- Click Edit in Settings.json
- Click the edit pencil -> Copy to Settings
- Enter the path to the git.exe. In Windows, search the User Appdata folder to find the install path. example C:\Users\myUserName\AppData\Local\GitHubDesktop\app-1.5.0\resources\app\git\mingw64\bin\git.exe. Remember to escape the "\" by substituing "\\", and surround the whole text in double quotes. In this case, the escaped path would be: "C:\\Users\\myUserName\\AppData\\Local\\GitHubDesktop\\app-1.5.0\\resources\\app\\git\\mingw64\\bin\\git.exe"
- Restart VS Code
- Select the Source Control icon on the left pane. There should now be a
(Optional) Install GitKraken
GitKraken is a great tool for viewing the status of all branches on your GitHub repository. Optionally install GitKraken to help you manage pushing and pulling changes from GitHub, and for viewing a nice graph of all branches and code comparisons for all commits.
During the install process, you can sign into GitKraken with your GitHub profile.
In order to allow GitKraken to help you manage your repository, you will need to allow 3rd party apps on your GitHub repository.
- log onto GitHub through the web interface
- navigate to the repository that you would like to authorize (can be a personal or organization repository)
- click settings -> Third-party access -> and Allow