B4J Tutorial [server] Run a Server on a VPS

Status
Not open for further replies.
The steps required to run a B4J server on a hosted server (such as a VPS) are:

1. Download Java: https://www.b4x.com/android/forum/t...lest-way-to-distribute-ui-apps.99835/#content

If you are not familiar with Linux then download it to your development computer, unzip it and upload the files with FTP. You do not need to install anything.

2. Upload the compiled jar with any additional files (www folder for example).

3. Start the server with:
B4X:
nohup path_to_java/bin/java -jar somejar.jar > nohup.out &
The console output will be written to nohup.out.
You need to use nohup as otherwise the server will be killed when you log out.

4. Make sure that the relevant port is open in the firewall settings.

5. If you want to kill the server you can use this command to find the process number:
B4X:
ps -ef | grep java
kill <process number>

6. Tip: Use tail -f nohup.out
To monitor the server logs.

If you see an error related to the temporary folder then explicitly set it with:
B4X:
nohup path_to_java/bin/java -Djava.io.tmpdir="temp" -jar somejar.jar > nohup.out &

If there is another http server running on the computer, like Apache or IIS, then you should not copy the B4J server to its public_html / www / or any other publicly accessible folder.
 
Last edited:

codie01

Active Member
Licensed User
Longtime User
Good Day Erel,

I have unzipped the jre to my computer, Ftp ready, which directory do I install these to?

Thanks Phil
 

codie01

Active Member
Licensed User
Longtime User
Hi all, Erel

Hope this is the right place. I have setup a VPS - Linux, I have installed Jetty and Java.

When I fire up Jetty all seems well and I can see the Jetty Logo etc when i browse the ip of the server xxx.xxx.xxx.xxx:8080

However when I run the server Jar I get a bundle error shown in red as follows:

---------------- LOG -----------------

2015-12-17 16:26:36.481:INFO::main: Logging initialized @526ms

2015-12-17 16:26:36.573:INFO:eek:ejs.Server:main: jetty-9.1.z-SNAPSHOT

2015-12-17 16:26:36.596:WARN:eek:ejh.MimeTypes:main: java.util.MissingResourceException: Can't find bundle for base name org/eclipse/jetty/http/encoding, locale en_US

2015-12-17 16:26:36.628:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@675d3402{/,0.0.0.0:51042}

2015-12-17 16:26:36.646:INFO:eek:ejs.Server:main: Started @698ms

---------------- LOG -----------------

Thanks in advanced,

Philip
 

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

How to(Or Could I) setting Multi-domain name for every APP when i running two or more B4J-APP in same VPS ? :(

Eaxmple:
a.com -> 192.168.1.1:8000 (APP1)
b.com -> 192.168.1.1:8001 (APP2)
 

shashkiranr

Active Member
Licensed User
Longtime User
Hi all,

I started my rdc server on the vps running centos 6 successfully using the below post by martin

http://www.b4x.com/android/forum/th...ect-to-any-remote-db.31540/page-8#post-217480

I opened the firewall port 51044 and confirmed it using the below code

B4X:
sudo iptables -I INPUT -p tcp -m tcp --dport 51044 -j ACCEPT

iptables -L -n

When I enter the server ip to access the test handler to check the connection to db, i get 404 not found error. Am i missing something? Kindly let me know

B4X:
http://serverip/test:51044

Best,
SK
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

achtrade

Active Member
Licensed User
Longtime User
I'm starting the server with this:

nohup /home/user/RDC-Server/jdk1.7.0_79/bin/java /home/user/RDC-Server/jdbc_driver/mysql-connector-java-5.1.22-bin.jar > nohup.out &

and I'm getting this error:

Error: could not find or load main class .home.user.RDC-Server.jdbc_driver.mysql-connector-java-5.1.22-bin.jar

what's wrong ?

thanks.
 

achtrade

Active Member
Licensed User
Longtime User
After add the -jar parameter,
nohup /home/user/RDC-Server/jdk1.7.0_79/bin/java -jar /home/user/RDC-Server/jdbc_driver/mysql-connector-java-5.1.22-bin.jar > nohup.out &

now I'm getting this error:

no main manifest attribute, in /home/user/RDC-Server/jdbc_driver/mysql-connector-java-5.1.22-bin.jar

any idea?
 

victormedranop

Well-Known Member
Licensed User
Longtime User
hi, I upload de Jar file run with nohup but I get an error in logs file.

it said is looking for :51042/ws/demo HTTP/1.1" 302 0 "-" ws folder, I cant find it. it's just testing the demo apps.

i'm using debian on a vps. Digital ocean. with java


root@dev01:~# java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

in windows works fine.

regards,

Victor
 
Last edited:
Status
Not open for further replies.
Top