B4J Question B4X Server Push

studio4

Member
Licensed User
Longtime User
Hello,
Nowadays, I am working on an application which reads tables of mysql to send notifications using Android Push Notification (GCM). After working and reading severla trheads I got that it works perfectly but... I have a new problem. I need to upload my .jar (file servlet generated by B4X) to my VPS server (With SSH and TomCat). The problem resides in that my file is .jar, and my server only lets me to upload files .war. Any idea? Do I need to convert my .jar to .war? How can I do it?. Thanks.
 

studio4

Member
Licensed User
Longtime User
is your VPS is a fresh install, you never tried it with your B4J jar ?

Sorry, I can not understand "fresh install". It is the first time that I create a file .jar with B4J to upload to a server.
 

Attachments

  • plesk java.png
    plesk java.png
    37.2 KB · Views: 267
Upvote 0

imbault

Well-Known Member
Licensed User
Longtime User
Are you sure, your VPS can run standalone Jar Applications?
Or is it a web application server (like TomCat...)
 
Upvote 0

imbault

Well-Known Member
Licensed User
Longtime User
Your application doesn't need any Web Application server, it encapsulates jServer (jetty). You have just to run it, the only prerequisite is the JRE, java runtime.
 
Upvote 0

studio4

Member
Licensed User
Longtime User
Your application doesn't need any Web Application server, it encapsulates jServer (jetty). You have just to run it, the only prerequisite is the JRE, java runtime.


Ok thanks. So, I only need upload the .jar file to a folder in my server (for example using ftp client) and to run it using SSH comand? but... please, Which is the command that I have to use?. Thanks a lot for your attention.
 
Upvote 0

studio4

Member
Licensed User
Longtime User
1. Make sure that Java JRE is installed. If not then download the linux JRE to your PC and upload the files with FTP to the server (no need to install it).
2. Run:
B4X:
<path to java>/bin/java -jar <your jar file>


Thanks Erel, thanks Imbault

I have tried the Erel's command and appears this error in my SSH console (image attached). What thing am I doing bad?. The .jar file works perfect in my local network (in my windows laptop).
 

Attachments

  • java_error.png
    java_error.png
    22.6 KB · Views: 238
Upvote 0

imbault

Well-Known Member
Licensed User
Longtime User
In B4J, which JDK version do you use?
(it's in your B4J Paths Configuration, line 1 javac.exe)

In your VPS, can you type a :
java -version

To know the JRE version installed?
 
Upvote 0

studio4

Member
Licensed User
Longtime User
You need to update to java 8.

You can check the java version with:
java -version


Pefect. Thanks for your help. Imbault, Erel... you are the best but I have a new little problem.

I put the Erel's command in my putty console (my SSH interface) and works fine ( I had to copy the config.txt in the same folder that .jar file), but when I close Putty (my SSH interface) the .jar stops. Any idea?

Thank you again
 
Upvote 0

imbault

Well-Known Member
Licensed User
Longtime User
This is because you close your shell session and killed the process.

You can autostart your Jar.
Edit the file /etc/rc.local add this command before exit 0
/usr/bin/java -jar <your jar file> &

You can edit rc.local using those commands:
cd /etc
sudo nano rc.local
 
Last edited:
Upvote 0

studio4

Member
Licensed User
Longtime User
This is because you close your shell session and killed the process.

You can autostart your Jar.
Edit the file /etc/rc.local add this command before exit 0
/usr/bin/java -jar <your jar file> &

You can edit rc.local using those commands:
cd /etc
sudo nano rc.local


Perfect. I resolved it.
I believe that this command will be to start .jar file when my server boots. At this moment, I solved the problem putting the character '&' at the end of the sentence and left my ssh console with the command exit. Thank you. I am very grateful.
 
Upvote 0
Top