GithubHelp home page GithubHelp logo

blackcorsair / install-jdk-on-steam-deck Goto Github PK

View Code? Open in Web Editor NEW
34.0 5.0 5.0 34 KB

Guide and script to install java jdk 17 or 21 on the steam deck

License: GNU General Public License v3.0

Shell 100.00%
java jdk jdk17 steamdeck jdk21

install-jdk-on-steam-deck's Introduction

install-jdk-on-steam-deck

How it works

By default, the SteamDeck has a read-only immutable OS file system, which means that you can't simply install anything using the pacman package manager that comes with the OS (arch linux), since it would modify the OS file system.

So in order to install anything outside the Software Center (which installs programs in a way that doesn't affect the OS by using flatpak), you have to modify things in you home directory, which shouldn't mess up with the OS and break the system.

Taking this into account, the script located in the scripts directory of this repository will:

  • Download the official oracle JDK 17 compressed file into your home directory, more specifically into ~/.local/jdk
  • Exec a checksum of the file using the official sha256 checksum
  • Extract the file into ~/.local/jdk/jdk-17.0.4.1
  • Add some environment variables to your ~/.profile and then source it, if it wasn't already sourced, in your bashrc, so your programs / scripts know where java is installed. The variables are:
    • JAVA_HOME: which points to the ~/.local/jdk/jdk-17.0.4.1
    • PATH: which adds the bin directory located in the JAVA_HOME, so every executable is available for you to run

By adding the variables to .profile instead of .bashrc we ensure to be more "shell agnostic", so if you run a script in another shell like sh or launch a graphical program, it should read the environment variables defined there.

.profile is "manually" sourced in .bashrc since bash will try to source first .bash_profile and .bash_login if they exist. To learn about this:

With this, you will have a local installation of java and even better, you can install multiple versions and then point to the one you need.

This script only works (currently) for the jdk-17, since in order to download jdk-11 from oracle's page requires a login.

Usage

You can choose which version to install by setting the variable JDK_VERSION before executing the script, you can even do it on the same command! If you don't select any version, jdk-17 will be installed by default.

To install jdk-17:

git clone https://github.com/BlackCorsair/install-jdk-on-steam-deck.git && \
JDK_VERSION=17 ./install-jdk-on-steam-deck/scripts/install-jdk.sh

To install jdk-21:

git clone https://github.com/BlackCorsair/install-jdk-on-steam-deck.git && \
JDK_VERSION=21 ./install-jdk-on-steam-deck/scripts/install-jdk.sh

How to uninstall it

# remove the installation directory this script creates
rm -rf /home/deck/.local/jdk

# remove the ~/.profile file this script creates OR remove the lines using an editor:
# export JAVA_HOME=/home/deck/.local/jdk
# export PATH=$PATH:/home/deck/.local/jdk/jdk-17.0.8/bin
rm -f ~/.profile

# Optionally, you can remove the line added to your bashrc
#
# [[ -f ~/.profile ]] && source ~/.profile
#
# This line shouldn't interfere with anything since it doesn't load the ~/.profile unless it exists

TO-DO

  • Add an uninstall script or option
  • Add support for java 8 (see issue)
  • If you want anything added, just let me know by opening an issue

install-jdk-on-steam-deck's People

Contributors

blackcorsair avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

install-jdk-on-steam-deck's Issues

No .profile / .bashrc files

Hello,

I am not very experienced Linux user as most of Steam Deck owners.
I tried installing Java via your script and noticed a small issue where I got a warning, here is the complete Konsole output of the installation:

JDK downloaded and extracted into /home/deck/.local/jdk
Setting environment variables if not already set
grep: /home/deck/.profile: No such file or directory
Checking that java is properly installed...
java version "17.0.8" 2023-07-18 LTS
Java(TM) SE Runtime Environment (build 17.0.8+9-LTS-211)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.8+9-LTS-211, mixed mode, sharing)
Java is succesfully installed!
To activate your java installation execute the following:

        source ~/.bashrc


Done

I noticed the issue caused by changing my Steam Deck name, so /home/deck/ became like /home/Bahamin-s-Deck/.
EDIT: I was wrong and the directory is not related to the device name, so it's still /home/deck/ after a double check

And as the result I am encountering unexpected behavior on every command I send to the Konsole.

The first command I have used was the command I was supposed to use after installation to activate Java:

(deck@Bahamin-s-Deck ~)$ source ~/.bashrc
bash: PROMPT_COMMAND: line 3: syntax error near unexpected token `;'
bash: PROMPT_COMMAND: line 3: `__steamos_prompt_command '(\[\033[1;32m\]\u@\h\[\033[1;34m\] \W\[\033[0m\])\$ '; __steamos_prompt_command '(\[\033[1;32m\]\u@\h\[\033[1;34m\] \W\[\033[0m\])\$ '; __steamos_prompt_command '(\[\033[1;32m\]\u@\h\[\033[1;34m\] \W\[\033[0m\])\$ '; ; '

So it doesn't matter what command I use at Konsole, I'll always get this error even if its ls command;
What would you suggest to do to fix this issue?

Thanks in advance.

Jdk 8 support

Greetings!

Could you add support for JDK8?

Maybe choose at the start of the script or a completely different script?

double clicking to run

i wan't able to run a shell script with java inside by double clicking. unless i added "[[ -f ~/.profile ]] && source ~/.profile" to .bash_profile. also to run a jar by double clicking I need to fix java.desktop "Exec=/home/deck/.local/jdk/jdk1.8.0_391/bin/java" by adding "-jar %f" like "Exec=/home/deck/.local/jdk/jdk1.8.0_391/bin/java -jar %f"

It is installed but how do you run a .jar file

So I was confused when you said "Exec a checksum of the file using the official sha256 checksum"
I assumed it ment copy the linux link and paste it into a the terminal and run it. Which I did and it said it successfully installed but how do I run my .jar file now that it is installed?

Request for showing this off in a video

Greetings,
After some search on the internet I found this page on github and I cannot thank you enough for creating the script. No one did a video about this on YouTube so a lot of people probably won't even bother to search for the Github page. Am I allowed to create a video showing off how to install java on the Steam Deck? If not I would highly suggest you make one yourself

Um Environment Variables?

Ok so you lost me at Environment Variables. Am I supposed to create a folder .profile? Because there isn't one there now. I tried educating my self on environment variables but not sure I am supposed to use them in context with what we are doing here. I don't suppose you have video tutorial?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.