Android Question jRDC2 on remote server

John Leeson

Member
Licensed User
Longtime User
Hi B4X people, I've made great use of this forum over the years but this is the first time I've been stuck enough to need to ask a question - I feel like I'm probably being stupid, but I'm in unfamiliar territory...

I have watched the tutorial on jRDC2 - my question is relating to getting the b4j server running on my remote server. And to be honest, I don't really follow the instructions!

On this link [server] Run a Server on a VPS the first step is to download java, from this link: B4JPackager11 - the simplest way to distribute UI apps, and at the top of that page it says, start with the integrated package manager, at this link: Integrated B4JPackager11 - The simple way to distribute standalone UI apps. But on reading that page, it is now integrated in B4J - Build standalone package - so is that all I need to do? do I then just have to upload the package and folders to the remote server, and then start it with the command line? as per step 3 on [server] Run a Server on a VPS?

I'm pretty sure I will have follow up questions!
 

John Leeson

Member
Licensed User
Longtime User
Thank you very much Aeric and and Erel. So I do have follow up questions...

As I understand it:
  1. Download java for linux from https://www.b4x.com/b4j/files/java/linux_jdk-14.0.1.zip
  2. unzip and then upload to server
  3. upload the .jar file of my jrdc project
  4. start java with nohup
  5. start my jrdc server with nohup
Does it matter where java and jrdc are placed? I read that the should not be inside public_html, so I should make a new folder at root level and put them in there?


so for example if I make a folder called jrdc, and inside that put the unzipped java jdk, and the jrdc jar file (called jRDC.jar) the command to start both would be:

B4X:
nohup jrdc/linux_jdk-14.0.1/jdk-14.0.1/bin/java -jar jrdc/jRDC.jar > nohup.out &


Screenshot 2023-04-30 073310.png


I've discovered I don't have permission to run the command so before I ask support to do it for me, I want to check it is correct, and I don't want to break anything. Thank you all for your patience!
 
Upvote 0

John Leeson

Member
Licensed User
Longtime User
Thanks Erel, so without nohup, in a folder called java that would be this?

B4X:
java/linux_jdk-14.0.1/jdk-14.0.1/bin/java -jar java/jRDC.jar
 
Upvote 0

udg

Expert
Licensed User
Longtime User
A quick one: is there any specific reason not to use a Java version fron the installed OS repository?
Since it'll be used on a server for non-UI "apps" (like jRDC2 or any other jetty-based solution) would the official OS repository JRE/JDK miss something important when used with such apps?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Thanks Erel, so without nohup, in a folder called java that would be this?
Yes, but you might want to switch to the project folder first. Otherwise the startup folder will be different.

Since it'll be used on a server for non-UI "apps" (like jRDC2 or any other jetty-based solution) would the official OS repository JRE/JDK miss something important when used with such apps?
It will work fine.
 
Upvote 0

John Leeson

Member
Licensed User
Longtime User
A quick one: is there any specific reason not to use a Java version fron the installed OS repository?
Since it'll be used on a server for non-UI "apps" (like jRDC2 or any other jetty-based solution) would the official OS repository JRE/JDK miss something important when used with such apps?
Would that mean that it would not be necessary to upload java to the server? only jRDC?

What I'm being told by my hosting company is that I can't run the command to start jrdc because CentOS v7.9 does not support it. I cannot upgrade CentOS because of the out of date php version required by an old website (I have an awkward client - I can't get around that issue at the moment) , but if jRDC could use an older version of java, e.g. 8.5, then it should work. Any thoughts?
 
Upvote 0

udg

Expert
Licensed User
Longtime User
I daily use a CentOS 7 VPS server where I installed Java 8 and MySql/Maria DB.
With that, any JServer-based (or jetty-based, if you prefer) solution works without problems.
 
Upvote 0

John Leeson

Member
Licensed User
Longtime User
Thanks, so, jrdc2 should run, but according to the web host, they can't run the actual command to start it.

e.g.
B4X:
java/linux_jdk-14.0.1/jdk-14.0.1/bin/java -jar java/jRDC.jar

without installing tomcat. I don't really understand but maybe the latest version of tomcat needs a more recent version of CentOS.

These are their messages
Good Morning,

I have installed Tomcat so this can execute however it looks to be compiled for class file version 53.0 (server version 52.0).

Bear with me while I look at updating thanks.

I will keep you posted.
Thanks for waiting John,

It looks like version 10 can be installed via a container however the current OS does not support this (CentOS v7.9)

https://docs.cpanel.net/ea4/containers/tomcat-via-containers/

Do you have a compiled version of jRDC.jar for Java 8.5?

The alternative is to provision a new server on Alma 8 with the latest versions and migrate, however, this has some caveats looking at the sites, as PHP 5+ is currently being targeted and would not be supported on the newer platform (only 7.2 and above).

I think maybe my only option is to use httppost and php / json if there is no way to get jrdc to work
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I don't think you need Tomcat installed.
jRDC is based on Jetty which is a server itself.


java/linux_jdk-14.0.1/jdk-14.0.1/bin/java -jar java/jRDC.jar


You may try this steps:

1. Make a directory in /usr/java
B4X:
sudo mkdir /usr/java

2. Copy the zip file to /usr/java (if you are uploading files to /usr/java using FTP Client then skip to step 6)
B4X:
sudo cp linux_jdk-14.0.1.zip /usr/java

3. Change directory
B4X:
cd /usr/java

4. Unzip the file
B4X:
unzip linux_jdk-14.0.1.zip

5. If the directory structure is not your liking, then move/rename as your liking
My structure look like this:
/usr/java/jdk-14.0.1/

6. Install java and javac as alternatives
B4X:
sudo update-alternatives --install /usr/bin/java java /usr/java/jdk-14.0.1/bin/java 100
sudo update-alternatives --install /usr/bin/javac javac /usr/java/jdk-14.0.1/bin/javac 100
Note: 100 is priority. You can use any number or 0 for automatic.

7. Check if you can execute java or javac
B4X:
java -version
javac -version

Edit:
8. If the java version is not correct, use:
B4X:
sudo update-alternatives --config java

9. Enter the number of java version you prefer
or just press enter to accept the default option (marked with plus sign +) to not making changes.
 
Last edited:
Upvote 0

John Leeson

Member
Licensed User
Longtime User
Thanks Aeric - I really appreciate your time.

According to
B4X:
java -version

The current version of java on the server is openjdk version 1.8.0_362

do I actually need to install a more recent version? It looks like I may not have permission to run these commands

B4X:
sudo update-alternatives --install /usr/bin/java java /usr/java/jdk-14.0.1/bin/java 100
sudo update-alternatives --install /usr/bin/javac javac /usr/java/jdk-14.0.1/bin/javac 100

To me this seems massively complicated :(.

Is using a post request, php script and returning json that bad? I can have that working in no time, whereas I've been trying to get jrdc to work for days
 
Upvote 0

John Leeson

Member
Licensed User
Longtime User
Hi Erel,

I've done that, but I can't get jRDC to start, so I'm stuck.

1.png

The jrdc2.jar is in the jrdc folder

so I should be able to start it with

B4X:
jrdc/linux_jdk-14.0.1/jdk-14.0.1/bin/java -jar jrdc/jRDC.jar

but as I can't run that code, it seems I'm stuck. I think I maybe need to try it on a different VPS
 
Upvote 0

John Leeson

Member
Licensed User
Longtime User
I get this:
2.png


I double checked with the hosting company, they said:

Hi John,

100% I am afraid. I can call it via /bin/java -jar jrdc/jRDC.jar however due to versions it will not run as it wants the next version.


EDIT - I also tried with the correct case for jrdc.jar / jRDC.jar
3.png
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Try add sudo in front the command.
e.g
B4X:
sudo linux_jdk-14.0.1/jdk-14.0.1/bin/java -jar jRDC.jar
Enter the root password when prompt.

I think it is better to put the jrdc folder inside home directory.
 
Upvote 0

John Leeson

Member
Licensed User
Longtime User
I put that to the web hosting company, and they came back with:

We cannot presently target jdk-14.0.1 due to the cPanel constraints as everything is managed by that. With cPanel installed everything must be installed through its package manager.

We could certainly try and install this under cPanel's radar but I would advise against it.

Their recommendation is to set up a new server, and once this is working on that, migrate all my accounts across
 
Upvote 0
Top