B4J Question Unable to compile the default server app

toby

Well-Known Member
Licensed User
Longtime User
I use the latest B4J and I han't noticed any problem until now when I tried to build a bare-bone server app.

What I've done:
1. Selected New project and Server type.
2. Changed nothing beside giving a unique package name to avoid conflicts
default code:
Sub Handle(req As ServletRequest, resp As ServletResponse)
    Try
        If req.GetSession.HasAttribute("myNumber") = False Then
            req.GetSession.SetAttribute("myNumber", Rnd(0, 101))
        End If
        Dim myNumber As Int = req.GetSession.GetAttribute("myNumber")
        Dim n As String = req.GetParameter("number")
        If IsNumber(n) = False Then
            resp.Write("Please enter a valid number.")
        Else
            If n > myNumber Then
                resp.Write("My number is smaller.")
            Else If n < myNumber Then
                resp.Write("My number is larger.")
            Else
                resp.Write("Well done!!!")
            End If
        End If
    Catch
        resp.SendError(500, "error....")
    End Try
End Sub
3. Clicked build and the errors appeared.
I got the following compiler errors:
B4X:
B4J Version: 9.80
Parsing code.    (0.00s)
    Java Version: 8
Building folders structure.    (0.00s)
Compiling code.    (0.00s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
Compiling generated Java code.    Error
B4J line: 3
End Sub
javac 1.8.0_342-342
src\b4j\example\guessmynumber.java:32: error: cannot access JServlet
public String  _handle(anywheresoftware.b4j.object.JServlet.ServletRequestWrapper _req,anywheresoftware.b4j.object.JServlet.ServletResponseWrapper _resp) throws Exception{
                                                  ^
  bad class file: C:\Program Files\Anywhere Software\B4J\libraries\jserver.jar(anywheresoftware/b4j/object/JServlet.class)
    class file has wrong version 55.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

What I did wrong?

TIA
 

toby

Well-Known Member
Licensed User
Longtime User
The installed Java on my VPS server Java 8 (1.8.0_342), to get bundled JavaFX, I downgraded earlier from Java 11 to Java 8 (1.8.0_331).

I just restored Java 11 and the error went away.
 
Upvote 0
Top