schorschii / RemotePointer-Server

PC software for the RemotePointer-App
GNU General Public License v3.0
23 stars 9 forks source link

Java error: Unknown host? #2

Closed hj-beckers closed 1 year ago

hj-beckers commented 2 years ago

When starting RemotePointer-Server.jar I get an UnKnownHostException:

~/downloads> java -jar RemotePointer-Server.jar Exception in thread "main" java.net.UnknownHostException: linux-43on: linux-43on: Der Name oder der Dienst ist nicht bekannt at java.base/java.net.InetAddress.getLocalHost(InetAddress.java:1646) at RemotePointerServer.RemoteSpotlight.main(RemoteSpotlight.java:140) Caused by: java.net.UnknownHostException: linux-43on: Der Name oder der Dienst ist nicht bekannt at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929) at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1519) at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:848) at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1509) at java.base/java.net.InetAddress.getLocalHost(InetAddress.java:1641) ... 1 more

~/downloads> hostname linux-43on

Do you expect a special java version?

~/downloads> java --version openjdk 11.0.14 2022-01-18 OpenJDK Runtime Environment (build 11.0.14+9-suse-3.74.2-x8664) OpenJDK 64-Bit Server VM (build 11.0.14+9-suse-3.74.2-x8664, mixed mode)

hj-beckers commented 2 years ago

No response?

schorschii commented 2 years ago

I don't think this is a Java version issue. According to https://stackoverflow.com/questions/7348711/recommended-way-to-get-hostname-in-java, the UnknownHostException thrown by InetAddress.getLocalHost().getHostName() it is rather a DNS issue, causing Java to not properly determine the machine's hostname.

Can you please post the output of

echo "import java.net.InetAddress; System.out.println(InetAddress.getLocalHost());" | jshell

and the content of your /etc/hosts file here?

schorschii commented 1 year ago

@hj-beckers no response?

lrq3000 commented 1 year ago

App works fine for me on Win11 Pro. I just had to reconnect multiple times. Please add in readme that it needs to be launched from commandline using java -jar RemotePointer-Server.jar

hjbeckers commented 1 year ago

Thanks for the timely reminder. After switching distros in the meantime (opensuse -> ubuntu) and using the latest versions of remotepointer it works fine.

schorschii commented 1 year ago

@lrq3000 , @hjbeckers thanks for your feedback.

@lrq3000 normally, .jar files can be executed with a simple double click, no need for command line. I tested this successfully on a fresh Windows 11 installation with Oracle JDK 21. With OpenJDK you may need to manually link .jar files with java.exe, see here.

Nevertheless, I think a rewrite (maybe in Python) is necessary in the future to improve user experience for end users. Python scripts can be compiled into single binaries which can be executed without installing a runtime first.

lrq3000 commented 1 year ago

I tried double clicking at first, and even tried to java RemotePointer-Server.jar, but both didn't work for some reason. I have the standard Java JRE, not OpenJDK, on Win11 Pro. No idea why it didn't work, but java -jar fixes the issue.

Oh yes it would be nice to rewrite into Python, but the app works great in its current state. Thank you very much for making this and under an opensource license!

lrq3000 commented 1 year ago

I skimmid through the codebase, it's relatively succinct, kudos for such a nice codebase! Yes it shouldn't be too hard to convert to Python (I am a long time pythonist), I'll see if someday i need or get an itch to convert to Python.