Hannes de Jager
Hannes de Jager

Reputation: 2923

Java on OpenWrt/DD-WRT

I have an existing solution written in Java which I would love to run on OpenWrt routers. Will OpenWrt even run Java without installing a lot of dependencies? Anyone ever tried this?

Upvotes: 16

Views: 29016

Answers (6)

Sergey Ponomarev
Sergey Ponomarev

Reputation: 3191

The Alpine Linux is also based on musl library so you may try to download the OpenJDK from their repository. Here is a sample how to install OpenJDK 8 to Turris Omnia router https://gist.github.com/stokito/7dd425da5a12abce8b39dda1bd1106d7

The Zulu OpenJDK have Alpine builds for x86_64 and armv8 64

The Eclipse Temurin (AdoptOpenJDK) doesn't have yet Alpine builds

Upvotes: 1

github_s
github_s

Reputation: 56

In the OpenWrt version 21.02, you can install Docker directly, so you can also try to run a Java app in a Docker container. You can also try Podman instead of the Docker.

But still the MIPS router probably won't be supported, only ARM. Try the eclipse-temurin images because they have a wide support of architectures. For example they have a build of OpenJDK 17 TLS for the arm v7. Their image is based on Ubuntu 22.04 and uses glibc inside of a container.

Upvotes: 1

feder
feder

Reputation: 2058

Use the Embeded JRE these days. http://www.oracle.com/technetwork/java/embedded/overview/index.html

It also exists for ARM and not only for Intel architecture platforms.

Upvotes: 1

Prof. Falken
Prof. Falken

Reputation: 24887

Since your goal is to get the existing solution running on the router, and not explicitly get a JVM running on the router, I would suggest going the other way:

compile the Java code to native! This also has the potential to be just as fast a C code.

There is an article in Linux journal about this.

If not your cup of tea, JAMVM seems a better fit for a small system such as OpenWRT.

Upvotes: 2

orftz
orftz

Reputation: 1148

I've never done it, but it is definitively possible. You won't be able to run the full Java VM, only specialized versions of it (JamVM, PhoneME, SableVM). Also please be aware that running a Java VM is fairly a lot overhead for this kind of machine.

I won't get much in detail because others have already done it. Check out these links.


EDIT: SableVM is unmaintained.

EDIT: As Amigable Clark Kant mentioned, you could compile your Java code to native by using the GNU Compiler for Java.

Upvotes: 15

PeterMmm
PeterMmm

Reputation: 24630

I have done this on a Asus WL-HDD some time ago with SableVM. The WL-HDD can run Debian and connect some memory/hdd through USB. But performance was really bad.

Upvotes: 1

Related Questions