ValveSoftware / ValveSoftware/steam-runtime

Executing jar without system java (JRE) on linux

Open
#741 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
1.5k
Forks
97
PR merge metrics
No merged PRs in 30d

Description

This issue is about a public attempt of transitioning my game on linux to have a bundled java version since systems java is no longer accessable.
Its public to possibly help people at steam to provide better assistance, it may also be usefull as an example. This is mostly due to @TTimo offering/asking about this.

Previous method:
There was a .sh (bash) file
-this bash file checked the systems java version via:
version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | awk -F '.' '{sub("^$", "0", $2); print $1$2}')
-this translated the version into a 2 digit number to then compare it and check if the java version is high enough
-the jar file is then executed via:
java -jar Cube\ Chaos.jar "$@" (the "$@" apparently
-this is a simple jar file produced by a Java IDE (in my case Eclipse) which is the game itself

This is no longer functional because steam launches the bash file without access to the systems java.

Disclaimer:
I have close to no experience with bash scripts, most of this is snippeted together.
Also I am releasing an update on the first of the next month so I may be a little slow to respond or do work on this.
I can only test on linux very slowly due to the virual machine beeing very slow and finicky, as such I have asked one of the people of the community for help, though this is obviouly still messy.

Attempt:
-This whole attempt is on a seperate devtest branch to make sure normal use is not impacted
-I have downloaded the newest linux openjdk jdk (oracle is not free to distribute) and added it to the folder which is the package
-I have modified the bash to be:

#!/bin/bash

cd ./linuxJdk/bin

java -jar ../../Cube\ Chaos.jar

read

-the read command is just there to keep the terminal open for the purpose of testing
-I have attempted it without the cd going into the java bin subfolder but without that the java command does not work, even if changed to /linuxJdk/bin/java -jar Cube\ Chaos.jar to include the path there.
-This does launch the file in some way however this approach has 2 problems so far:
--Presumably due to beeing opened from a different path the game cannot find its own assets, I have no idea how to possibly be in the java path as well as in the main game path, but likely am just missing some bash knowledge. Could also be some other problem who knows.
--For some reason when the bash is executed manually steam automaticly tries to launch as well and adds its log to the bash terminal, this is quite perplexing considering the previous bash file did not do this. I am currently using https://github.com/code-disaster/steamworks4j to connect to steam with the game for stuff like friends list info and achievements, however this shouldent launch steam nor has it in the past. Additionally the game is made to work fine even without steam. This is not strictly required to fix but would make the game more susceptible to future problems.

Questions:
-Is there a common way to launch jar games via steam which doesnt require this messy bash workaround?
-Any ideas on how to resolve the bash folder issue?
-Any idea why manually executing the bash also launches steam?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the bash launcher and the linuxJdk/bin layout described in the issue, including how Cube Chaos.jar is invoked. Reproduce the Steam launch and asset-path behavior on Linux, then define completion as a bundled-Java launch that preserves the game's asset path and explains the unexpected Steam behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, java, shell
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.