B4J Question [SOLVED][Server] How I can compile/build HelloWorld example for Synology NAS?

DonManfred

Expert
Licensed User
on my NAS Synology DS215J
I don´t think you can run B4J Apps (UI and NonUI) on this Device. It does not have java installed. And you are not able to install it.
The Device is a NAS and not a SERVER

Well: what I've to do?

Install the App on your VPS or Server. Both must have java installed and able to run java apps.
 
Upvote 0

Elric

Active Member
Licensed User
Thank you Erel and DonManfred!

Well
Install the App on your VPS or Server. Both must have java installed and able to run java apps.

Dummies question: how I can create the App?

Usually I use the "Build standalone package" in "Project" menu for UI app. But for the server? If I use the same command I get an error:
ErrorBuildStandalonePackageForServer.png


Well, what I have to do?


I don´t think you can run B4J Apps (UI and NonUI) on this Device. It does not have java installed. And you are not able to install it.
The Device is a NAS and not a SERVER

I've assumed I could run the Erel's example onto NAS because the Erel's example may run on PC and raspberry and because NAS give me the availability to install the following packages:
  • Java8 (developped by Synology);
  • Java SE Embedded 8 (Oracle);
  • Maria DB 10 and 5;
  • phpAdmin;
  • PHP up to version 7.4.
and this tutorial: https://www.synology.com/en-us/know...ication/How_to_host_a_website_on_Synology_NAS.

Moreover, I've also taken in consideration the Erel's hint above:

I'd like to discover if my assumption is correct but to try that I've to solve my dummies question above. :)
 
Last edited:
Upvote 0

José J. Aguilar

Expert
Licensed User
I don´t think you can run B4J Apps (UI and NonUI) on this Device. It does not have java installed. And you are not able to install it.
The Device is a NAS and not a SERVER
Synology devices runs an operating system called DSM. They can act as a server. In fact, I run a mysql+php web server on it.
You can install the java package too, and I run a jRDC2 server on it too with, so probably any other kind of server.



what I've to do?

Install java package
1605084375880.png


Run a task in the task manager (try the command with the ssh console)

B4X:
nohup /var/packages/Java8/target/j2sdk-image/bin/java -jar /volume1/web/jRDC.jar > /volume1/web/nohup.out

1605085050323.png
 
Upvote 0

Elric

Active Member
Licensed User
Thank you!
You don't need to build a package. Make sure that #MergeLibraries is set to true
1605165934436.png
Ok, it is set to true.

and run your program in release mode.
1605165874109.png
done.

1. I've run in release mode three times, with three different JDK (changing "configure path"):
  • jdk1.8.0_191
  • jdk-11.0.1
  • jdk-14.0.1
and I've gotten three different files that I renamed and put them in web directory of my NAS:
1605166420553.png


2. Java8 is already installed on my NAS
1605166748275.png


3.
Run a task in the task manager (try the command with the ssh console)
Not clear for me, sorry. Do you mean this link?

4. Despite the no. 3, in "Panel Control -> Task Scheduler -> Create -> Triggered Task > User-defined script" I've created a new task:

1605168941792.png

and I've put the following code in Task Settings:
B4X:
nohup /var/packages/Java8/target/j2sdk-image/bin/java -jar /volume1/web/HelloWorld01-8.jar > /volume1/web/nohup.out
1605169086179.png


5. Then in "Panel Control -> Task Scheduler", I've selected my task and clicked "Run".

6. In my browser, I've put the address: "http://192.168.1.18:8888/" (IP LAN NAS is "192.168.1.18") and gotten this error:
1605169680031.png

🤔
 

Attachments

  • 1605167123408.png
    1605167123408.png
    34.1 KB · Views: 49
  • 1605167405371.png
    1605167405371.png
    21.6 KB · Views: 46
  • 1605168984487.png
    1605168984487.png
    353.7 KB · Views: 53
Upvote 0

Elric

Active Member
Licensed User
Where have you copied it? To /volume1/web/?
Yes. I'm in RAID 1. I've access just to volume 1 with file manager. By the way, is the same directory of the jar file.

I mean at least your getting a response from the server (Jetty message...)
Yes, I've understood that. I was just sarcastic with myself!

It is a very good result for me getting a response by Jetty, just missing the final result and I don't understand why.
 
Upvote 0

Elric

Active Member
Licensed User
I've tried:
  • to unzip the original example and to compile it in release mode (jdk1.8.0_191)
  • to change NAS folder:
1605216122752.png

  • to restart the NAS.
The task seems to be ok because the file "nohup.out" is created. Opening this file with text editor I can read just "Server started".

The 404 error is still present.

Why?!? :eek:
 
Upvote 0

Elric

Active Member
Licensed User
Moreover:
B4X:
http://192.168.1.18:8888/hello
works partially:
1605217980019.png

without image (but "logo.png" is in "www/images") and "back" link bring me to "192.168.1.18:8888" with the same 404 error.

(same result both Chrome and Firefox).
 
Upvote 0

Elric

Active Member
Licensed User
You haven't put the www folder in the correct place.
Thank you Erel. I've tried to understand where is the correct place.

Then, as first thing, reading post #1 of this thread and following the hint of JoséJ. Aguilar, I've turned back in "web" directory instead of "public" and put everything in apposite "srvHelloWorld", with the aim to separate this project by every other thing:
1605267526850.png

and then updated the task:
B4X:
nohup /var/packages/Java8/target/j2sdk-image/bin/java -jar /volume1/web/srvHelloWorld/HelloWorld8.jar > /volume1/web/srvHelloWorld/nohup.out

I've also put a Log command in b4j project:
B4X:
    srvr.StaticFilesFolder = File.Combine(File.DirApp, "www")
    Log(File.DirApp)
    srvr.LogsFileFolder = File.Combine(File.DirApp, "logs")
    srvr.AddHandler("/hello", "HelloPage", False)
    srvr.AddHandler("/FormExampleHelper", "FormExampleHelper", False)
    srvr.AddHandler("/FileUpload", "FileUpload", False)
thinking that maybe this would have given me some more info.

I've tried to put the "www" folder in:
  • same folder where HelloWorld8.jar is (i.e. as subfolder - please see image above)
  • same folder where folder containing HelloWorld8.jar is (i.e. both "www" and "srvHelloworld" folders are in "web" folder)
  • in the main directory of NAS (i.e. "www" folder at same level of "web" folder)
Then, I've restarted the NAS.

But without success.

The command Log(File.DirApp) returns me a simple "/" in noh.out file (nothing that the 404 error doesn't already give me) a part the other log command "Server started".

Maybe should I change something in the code to adapt it to NAS architecture?
 
Upvote 0

Elric

Active Member
Licensed User
EUREKA! 🥳

Thank you very much! The solution was simpler than I could imagine!

At the beginning I've got "ERROR_CONNECTION_REFUSED" but adding "/volume1/web/srvHelloWorld/" before "HelloWordl8.jar" it works perfectly!!!

Then, the working code in "Panel Control -> Task Scheduler -> Create -> Triggered Task > User-defined script":
B4X:
cd /volume1/web/srvHelloWorld
nohup /var/packages/Java8/target/j2sdk-image/bin/java -jar /volume1/web/srvHelloWorld/HelloWorld8.jar > /volume1/web/srvHelloWorld/nohup.out

YES!✌ YES! 😎
 
Upvote 0

Dadaista

Active Member
Licensed User
Hi
That is not working on my synology

Must I copy the files from www dir of the project to the dir where I copied file.jar in the synology?
Must I execute additional .jar/task in the synology to execute this example?

I have added the task
B4X:
nohup /var/packages/Java8/target/j2sdk-image/bin/java -jar volume1/web/webapp/HelloWorld/WebAppHelloWorld.jar > /volume1/web/webapp/HelloWorld/nohup.out
I am running another web Server in port 80/443
nohup.out is empty
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Hi
That is not working on my synology

Must I copy the files from www dir of the project to the dir where I copied file.jar in the synology?

You must copy the entire www folder as it is in B4j objects folder.


Must I execute additional .jar/task in the synology to execute this example?

I have added the task
B4X:
nohup /var/packages/Java8/target/j2sdk-image/bin/java -jar volume1/web/webapp/HelloWorld/WebAppHelloWorld.jar > /volume1/web/webapp/HelloWorld/nohup.out
I am running another web Server in port 80/443
nohup.out is empty

I am also interested in this question. Is DSM multitasking? The nohup command, is it able to maintain alive 2 different programs?
 
Upvote 0
Top