Java Web Start Bash rebuild

Java Nov 12, 2019

After Oracle have the new licence applied, many companies have problems to update her Java runtime to OpenJDK, because they need the JavaWebStart which is only shipped with the Oracle JRE.

It depends on your usecase, but for me the simples was to build a little bash script which does the job.

#!/bin/bash

if [ "$1" = "" ]; then
	echo "Usage: $0 URL update"
        exit 1
fi

execjava=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

echo "downloading $1 ..."

curl $1 > webstart.jnlp 

shift

if [ "$1" = "update" ]; then
	shift
	codebase=$( cat webstart.jnlp | grep codebase | cut -d'"' -f2 )
	echo $codebase
	jars=($( cat webstart.jnlp | grep jar | cut -d'"' -f2 | tr '\n' ' ' ) )
	mkdir jrw lib
	for i in "${jars[@]}"
	do  
		curl "$codebase$i" > $i
	done

fi

classpath=$( find . -type f | tr '\n' ':' )
classpath=${classpath::-1}

args=$( cat webstart.jnlp | grep argument | cut -d '>' -f2 | cut -d '<' -f1 | tr  '\n' ' ' )

exec "$execjava" -classpath $classpath main.MainFrame $args

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.