debian-setup

Java SDK

Debian promotes OpenJDK.

To install the JDKs,

sudo apt-get install openjdk-17-jdk
sudo apt-get install openjdk-17-source

Note source installs at /usr/lib/jvm/java-17-openjdk-amd64/src.zip.

To list the available Java runtime packages,

apt-cache search --names-only 'java.*runtime'

To list the available Java SDKs,

apt-cache search --names-only 'jdk'

To choose which version of Java to run as the default,

sudo update-alternatives --config java

Java Applications

All of the Java tools are self-contained. Instead of installing them via apt-get, do the following for each app:

  1. Download the latest version
  2. Unpack it in ~/Applications
  3. Add the executable to the PATH environment variable in ~/.bashrc

Install the following Java apps following the above steps:

Bash Environment

Add the following to ~/.bashrc:

# $JAVA_HOME is needed by certain Java apps.
# But no need to add $JAVA_HOME on $PATH; Java should already be on $PATH
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"

export ANT_HOME="${HOME}/Applications/apache-ant-1.10.12"
PATH="${ANT_HOME}/bin:${PATH}"

export MAVEN_HOME="${HOME}/Applications/apache-maven-3.8.6"
PATH="${MAVEN_HOME}/bin:${PATH}"

export GROOVY_HOME="{HOME}/Applications/groovy-4.0.7"
PATH="${GROOVY_HOME}/bin:${PATH}"

export GRADLE_HOME="${HOME}/Applications/gradle-7.6"
PATH="${GRADLE_HOME}/bin:${PATH}"

export SCALA_HOME="${HOME}/Applications/scala-3.2.1"
PATH="${SCALA_HOME}/bin:${PATH}"

export SBT_HOME="${HOME}/Applications/sbt-1.8.0"
PATH="${SBT_HOME}/bin:${PATH}"

export PLAY_HOME="${HOME}/Applications/play-2.8.18"
PATH="${PLAY_HOME}:${PATH}"

Note this approach has the advantage of keeping multiple versions of the same app and easily switch the versions in ~/.bashrc. If a version of an app is not needed, just remove the folder and its content.

Remember to source ~/.bashrc in ~/.bash_profile if you haven’t done so already (see shell).

Eclipse

  1. Download Eclipse Standard Edition, unpack it in ~/Applications.

  2. The unpacked Eclipse is in folder eclipse. Rename it to the full name of that of the downloaded package, e.g. eclipse-java-neon-1a, so that a) we can track the version of Eclipse and b) multiple distributions of Eclipse can coexist.

  3. vim <eclipse-folder>/eclipse.ini, add:

     -XX:MaxPermSize=512m
     -Xss1m
     -Xms1024m
     -Xmx4096m
    

    For Luna SR2 on Debian, also add the following lines in eclipse.ini before launcher.appendVmargs

     --launcher.GTK_version
     2
    

    Note, on a Mac, the ini file is located at Eclipse.app/Contents/MacOS/eclipse.ini.

  4. Add the file ~/.local/share/applications/eclipse-java.desktop. This should add the Eclipse app to the desktop menu.

     [Desktop Entry]
     Name=Eclipse Java
     Comment=Java IDE
     Exec=/home/<usr>/Applications/eclipse-java-neon-1a/eclipse
     Icon=/home/<usr>/Applications/eclipse-java-neon-1a/icon.xpm
     Terminal=false
     Type=Application
     Categories=Development;Programming;IDE;
     StartupNotify=true
    
  5. Note we can install multiple distributions of Eclipse. We can even customize the same distribution of Eclipse and keep the customized copies for different purposes. For example, make a copy of the Eclipse folder at step 2 and give it a different configuration at step 4. This is how I keep two Eclipse, one for Java, one for Scala. Here is the Eclipse Scala desktop entry file (~/.local/share/applications/eclipse-scala.desktop):

     [Desktop Entry]
     Name=Eclipse Scala
     Comment=Scala IDE
     Exec=/home/<usr>/Applications/eclipse-scala-SDK-4.0.0-vfinal-2.11/eclipse
     Icon=/home/<usr>/Applications/eclipse-scala-SDK-4.0.0-vfinal-2.11/icon.xpm
     Terminal=false
     Type=Application
     Categories=Development;Programming;IDE;
     StartupNotify=true
    
  6. Install the Scala plugin (alternatively there is a customized distribution of Eclipse for Scala)
    • Eclipse update site: http://download.scala-ide.org/sdk/helium/e38/scala211/stable/site
    • Installed the following
      • Scala IDE for Eclipse
      • ScalaTest
    • When Eclipse restarts, it will run Setup Diagnostics
      • Make sure JDT Weaving is checked
  7. Customization
    • At startup, it asks for the default work space folder. Point it at ~/Workspace.
    • Font: Window -> Preferences -> General > Appearance -> Colors and Fonts -> Basic -> Text Font. Choose Droid Sans Mono.
    • If Droid Sans Mono is chosen as above, bold fonts can mess up the spacing. Window -> Preferences -> Java -> Editor -> Syntax Coloring, uncheck all the bold fonts.
    • Spaces-Only: Window -> Preferences -> Java -> Code Style -> Formatter.