B4J Question B4X Server Push

Discussion in 'B4J Questions' started by studio4, Aug 21, 2015.

  1. studio4

    studio4 Member Licensed 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.
     
  2. imbault

    imbault Well-Known Member Licensed User

    is your VPS is a fresh install, you never tried it with your B4J jar ?
     
  3. studio4

    studio4 Member Licensed User

    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.
     

    Attached Files:

  4. imbault

    imbault Well-Known Member Licensed User

    Are you sure, your VPS can run standalone Jar Applications?
    Or is it a web application server (like TomCat...)
     
  5. studio4

    studio4 Member Licensed User

    Correct, My web application server works with TomCat.
     
  6. imbault

    imbault Well-Known Member Licensed User

    Ok, do your B4J app encapsulates Jetty? (jServer lib)
     
  7. studio4

    studio4 Member Licensed User

    I do not know it... theese are my libreries...
     

    Attached Files:

  8. imbault

    imbault Well-Known Member Licensed 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.
     
  9. studio4

    studio4 Member Licensed User


    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.
     
  10. Erel

    Erel Administrator Staff Member Licensed 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:
    Code:
    <path to java>/bin/java -jar <your jar file>
     
    LucaMs likes this.
  11. studio4

    studio4 Member Licensed User


    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).
     

    Attached Files:

  12. imbault

    imbault Well-Known Member Licensed 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?
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    You need to update to java 8.

    You can check the java version with:
    java -version
     
  14. studio4

    studio4 Member Licensed User


    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
     
  15. imbault

    imbault Well-Known Member Licensed 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: Aug 24, 2015
  16. studio4

    studio4 Member Licensed User


    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.
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    I'm using nohup to start B4J servers.

    For example:
    Code:
    nohup ../jdk/bin/java -jar somejar.jar > nohup.out &
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice