Re: Is there a way to get direct execution of java jar files in FreeBSD?

From: Pete Wright via questions <questions_at_freebsd.org>
Date: Tue, 12 Oct 2021 14:45:32 UTC

On 10/12/21 2:48 AM, list-freebsd-questions@jyborn.se wrote:
> I want to start a java jar file from inetd in FreeBSD 12.
>
> It seems I need to do this with the command java -jar xxx.jar,
> since I can't find a way to get direct execution of jar files.
>
> The java -jar method works fine, but the problem is that xxx.jar
> needs to know the IP address of the connecting client, and it should
> get that via the function System.inheritedChannel(), but it doesn't.
>
> Could it be that the java -jar start method in inetd doesn't transfer
> the client socket to xxx.jar?
>
> Anyway, that's why I wonder if there is a way to start xxx.jar without
> java -jar.

it really depends on how the Java program itself expects to be 
executed.  I have some spring-boot services that work fine when started 
up via daemon(8) on FreeBSD.  I actually use a wrapper shell script to 
prepare the app's appropriate environment variables then just have it 
execute "java -jar my-app.jar".

this should also work fine under inetd but i would be careful there as 
often times spinning up the JRE is an expensive and time consuming 
operations, so if possible i'd suggest just running as a long running 
daemon.

from what you describe above it sounds like it may be a bug in the app 
itself getting the IP addresses of clients.

-p

-- 
Pete Wright
pete@nomadlogic.org
@nomadlogicLA