Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 27 Next »

Fully hand-held tutorial on setting up the Java environment to a usable state as quickly as possible. Only knowledge of using the terminal is expected. This tutorial will be completely self-contained (excluding links to downloads).

For more detailed tutorials, see General Development Environment Setup Guide

The general steps are:

  • Install Java
  • Install Gradle
  • Import Repositories
  • Install and configure IDE


Ubuntu



Java


Macro lookup error: excerpt "OpenJDK" was not found on page "Java" (with ID 14844118) in space "PUBLIC".

If you're experiencing issues please see our Troubleshooting Guide.

Gradle


We are currently on Gradle 7. We will install it manually for ease of understanding. The official guide is here for reference. (Aside: we do not use the Gradle Wrapper)

  • Download the latest Gradle 7 distribution (7.4.2 as of writing).
    • Choose the "complete" version.
    • Remember where you downloaded it.
  • Unpack Gradle (the following are excerpted from the gradle website)

    • Open a terminal

    • cd into the directory where you downloaded Gradle. Then

    • Unzip the distribution zip file in the directory of your choosing, e.g.:
    $ sudo mkdir /opt/gradle
    $ sudo unzip -d /opt/gradle gradle-7.4.2-all.zip

  • Add to path

    $ echo 'export PATH=$PATH:/opt/gradle/gradle-7.4.2/bin' >> ~/.bashrc 
  • Verify installation

    • Open a console (or a Windows command prompt) and run gradle -v to run gradle and display the version, e.g.:
    $ gradle -v
    
    ------------------------------------------------------------
    Gradle 7.4.2
    ------------------------------------------------------------

  • Configure for IHMC software

      • Navigate to your user home directory.
      • Show hidden files.
      • Ensure the existence of the file ~/.gradle/gradle.properties on Ubuntu or C:/Users/<user>/.gradle/gradle.properties on Windows.
      • If it is not there, create it manually. This file's settings will override project and system level settings.
    • Copy paste the following lines into the file
    • Open Source Only:
      gradle.properties
      org.gradle.jvmargs=-Xmx4g

Import Repositories


In your system home folder (or C:/ drive in Windows), create a repository-group.

Option 1:

Use repository-collections to clone a predefined set of repositories. If you are working on humanoids, use humanoids.repos .

Option 2:

Use Git to manually clone the repository group:

  1. Clone repository-group.
    You may name that repository-group folder something else, like "primary" or "secondary" which helps when you have more than one.
  2. Inside the repository-group folder, clone the repositories you need. See
    For just ihmc-open-robotics-software
    It should look like:
repository-group
├── ihmc-open-robotics-software
│   └── build.gradle
│   └── gradle.properties
│   └── settings.gradle
├── <other IHMC repositories as needed>
├── build.gradle
├── gradle.properties
└── settings.gradle

We will be cloning repositories from the command line. 

Open a terminal and cd to a directory where you want to hold your files. The directory is arbitrary, but you will need to remember it.

First, consider a name for your repository group. "repos" works if you only need one workspace. That name will referred to as <repo-name> below.

Run the following:

$ git clone https://bitbucket.ihmc.us/scm/libs/repository-group.git <repo-name>
$ cd <repo-name>
$ git clone https://bitbucket.ihmc.us/scm/libs/ihmc-open-robotics-software.git

Your folder structure should now match what is shown in the next section.

IDE


This guide currently only contains instructions for IntelliJ. We are working on Eclipse.

Eclipse

Full guide: Eclipse IDE

Intellij

Full guide: IntelliJ IDEA

  • Download IntelliJ Community. 
    • https://www.jetbrains.com/idea/download/#section=linux
    • Open a terminal and cd into the folder where you downloaded the tar file
    • Extract the file and move it to /opt/. (If you already downloaded from the link above, there is no need to run curl). Replace the names appropriately based on the version you download.

    • $ curl -sL https://download.jetbrains.com/idea/ideaIC-2022.1.3.tar.gz -o idea.tar.gz
      $ tar -xzf idea.tar.gz
      # mv idea-IC-221.5921.22/ /opt/.
      # rm /opt/idea
      # ln -s /opt/idea-IC-221.5921.22/ /opt/idea
      # ln -s /opt/idea/bin/idea.sh /usr/local/bin/idea
    • IntelliJ is now runnable from the command line:

      $ idea
      

    • If the desktop launcher is not automatically created, you can open IntelliJ once and select Tools > Create Desktop Entry

  • Now you will need to configure IntelliJ to the Java environment you installed.
    • Set the Java SDK that you downloaded.
      • Go to File > Project Structure > Project Settings > Project.
      • Set the <SDK> to Java 17
      • Set the <Language Level> to SDK Default.
    • Set the gradle version.
      • Go to File > Settings > Build, Exectution, Deployment > Build Tools > Gradle. 
      • Set <Use Gradle From> and select Specified Location. Select the location where you installed gradle to.
        • On windows, this will be C:/Gradle/gradle-8.x
        • On Ubuntu, this will be /opt/gradle/gradle-8.x
      • Set <Gradle JVM> to Project SDK. This should point to the Java SDK you set in the previous step.
  • Your environment should be ready at this point. Import repository-group.
    • File > Open... > select repository-group
    • Gradle will take some time to build and index...
    • Your projects bar should then look like this (depending on the repositories you cloned):

    • where all repositories have a blue square on the folder icon indicating they were recognized by gradle as modules.


Windows



Git

This will be used for all terminal interactions on Windows. Access by searching for Git Bash on the windows search.

Hereby, "open a terminal/console" will refer to launching git bash.

Java


We use Java 17.

Oracle (recommended)

Download installer from https://www.oracle.com/java/technologies/downloads/#java17. The x64 MSI installer is the most convenient. Default installation settings are fine.

Verify installation. Open a terminal and call

java -version

Something like the following should be outputted:

java version "17.0.3.1" 2022-04-22 LTS
Java(TM) SE Runtime Environment (build 17.0.3.1+2-LTS-6)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.3.1+2-LTS-6, mixed mode, sharing)


Aside: java will be installed at the location

C:\Program Files\Java

Gradle


We are currently on Gradle 7. We will install it manually for ease of understanding. The official guide is here for reference. (Aside: we do not use the Gradle Wrapper)

  • Download the latest Gradle 7 distribution (7.4.2 as of writing).
    • Choose the complete version.
    • Remember where you downloaded it.
  • Unpack Gradle (the following are excerpted from the gradle website)

    • Create a new directory C:\Gradle with File Explorer.
    • Open a second File Explorer window and go to the directory where the Gradle distribution was downloaded. Double-click the ZIP archive to expose the content. Drag the content folder gradle-7.4.2 to your newly created C:\Gradle folder.

  • Add to path

    • In File Explorer right-click on the This PC (or Computer) icon, then click Properties -> Advanced System Settings -> Environmental Variables.
    • Under System Variables select Path, then click Edit. Add an entry for C:\Gradle\gradle-7.4.2\bin. Click OK to save.

  • Verify installation

    Open a console (or a Windows command prompt) and run gradle -v to run gradle and display the version, e.g.:

    $ gradle -v
    
    ------------------------------------------------------------
    Gradle 7.4.2
    ------------------------------------------------------------

  • Configure for IHMC software
      • Navigate to your user home directory.
      • Show hidden files.
      • Ensure the existence of the file ~/.gradle/gradle.properties on Ubuntu or C:/Users/<user>/.gradle/gradle.properties on Windows.
      • If it is not there, create it manually. This file's settings will override project and system level settings.
    • Copy paste the following lines into the file
    • Open Source Only:
      gradle.properties
      org.gradle.jvmargs=-Xmx4g

Import Repositories


In your system home folder (or C:/ drive in Windows), create a repository-group.

Option 1:

Use repository-collections to clone a predefined set of repositories. If you are working on humanoids, use humanoids.repos .

Option 2:

Use Git to manually clone the repository group:

  1. Clone repository-group.
    You may name that repository-group folder something else, like "primary" or "secondary" which helps when you have more than one.
  2. Inside the repository-group folder, clone the repositories you need. See
    For just ihmc-open-robotics-software
    It should look like:
repository-group
├── ihmc-open-robotics-software
│   └── build.gradle
│   └── gradle.properties
│   └── settings.gradle
├── <other IHMC repositories as needed>
├── build.gradle
├── gradle.properties
└── settings.gradle


We will be cloning repositories from the command line. 

Open a terminal and cd to a directory where you want to hold your files. The directory is arbitrary, but you will need to remember it. Run

$ git clone https://bitbucket.ihmc.us/scm/libs/repository-group.git
$ cd repository-group
$ git clone https://bitbucket.ihmc.us/scm/libs/ihmc-open-robotics-software.git

Your folder structure should now match the above.


Long Paths


Long paths needs to be configured on Windows for our repositories.

Step 1: Run Registry Modifier

Download and run this script to apply the fix –>  Remove 260 Character Path Limit.reg

Reverting

If you need to go back for some reason, run this file:

Restore 260 Character Path Limit (Default).reg


*  Solution source: https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/

Step 2: Set Git configuration core.longpaths = true 

Set core.longpaths to true.

git config --global core.longpaths true

IDE


This guide currently only contains instructions for IntelliJ. We are working on Eclipse.

Eclipse

full guide: Eclipse IDE

Intellij

full guide: IntelliJ IDEA

  • Download IntelliJ Community. Choose the .exe for convenience
  • Now you will need to configure IntelliJ to the Java environment you installed.
    • Set the Java SDK that you downloaded.
      • Go to File > Project Structure > Project Settings > Project.
      • Set the <SDK> to Java 17
      • Set the <Language Level> to SDK Default.
    • Set the gradle version.
      • Go to File > Settings > Build, Exectution, Deployment > Build Tools > Gradle. 
      • Set <Use Gradle From> and select Specified Location. Select the location where you installed gradle to.
        • On windows, this will be C:/Gradle/gradle-8.x
        • On Ubuntu, this will be /opt/gradle/gradle-8.x
      • Set <Gradle JVM> to Project SDK. This should point to the Java SDK you set in the previous step.
  • Your environment should be ready at this point. Import repository-group.
    • File > Open... > select repository-group
    • Gradle will take some time to build and index...
    • Your projects bar should then look like this (depending on the repositories you cloned):

    • where all repositories have a blue square on the folder icon indicating they were recognized by gradle as modules.




  • No labels