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:

Beknazar

Member
Licensed User
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.

Erel,
please explain how to start server?
Where it is necessary to write?
thanks
 

avalle

Active Member
Licensed User
Perhaps just useful for noobs...
B4X:
nohup path_to_java/bin/java -jar somejar.jar > nohup.out &

somejar.jar
  • replace the filename with you B4J compiled JAR file.
  • Compile the server app in Release mode.
  • The compiled JAR file can be found in the Objects folder within your B4J project folder.
  • The default name is "result.jar". You can rename it as you like (still keeping the .jar extension ideally).
nohup.out
  • It's the file containing the console output.
  • Rename it as you like.
 

ajk

Active Member
Licensed User
The question may be a bit about the topic: how much theoretically you can squeeze from this type of server? I mean the maximum number of simultaneously served customers.
100 ?, 1000 ?, 1000,000?
 
Status
Not open for further replies.
Top