B4J Question [SOLVED] How to Create a Download Server?

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

How to create a non UI B4J server to serve as a host for download file from B4A App?

I want to download a file from B4A using this method :
 

incendio

Well-Known Member
Licensed User
Longtime User
Note that you don't need to implement anything for this. Just run the server and you can serve files from the 'WWW' folder.
Since I only need download service, I changed the codes into these
B4X:
Sub AppStart (Args() As String)
    srvr.Initialize("srvr")
    srvr.Port = 54021
    srvr.Start
    Log("Server started")
    StartMessageLoop
End Sub

On B4J IDE, it runs OK, but on command prompt, with this command
B4X:
java -jar FileServer.jar

Error raised :
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: anywheresoftware/b4a/BA
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: anywheresoftware.b4a.BA
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more

I am using java version "1.8.0_201"
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…