B4J Question java.io.FileNotFoundException

T201016

Active Member
Licensed User
Longtime User
Hi everyone,

I use:
B4J version 4.20(1)
JDK version 1.8.0_74

Code: Copy
#Region Project Attributes
    #MainFormWidth: 500
    #MainFormHeight: 300
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Public lv1 , lv2 As ListView
    Private SplitPane1 As SplitPane
    Private SplitPaneAnchorL As AnchorPane
    Private SplitPaneAnchorR As AnchorPane
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("ListViewLayout")    '------------- ListViewLayout.FXML !
    MainForm.Title="Split Pane - Accessing nodes?"
    MainForm.Show
    '
    lv1.Items.Initialize
    lv1.Items.Add("First entry")
    ' lv2 lives inside a split pane.
    ' ** ERROR - object should be initialised first
    ''lv2.Items.Initialize
    ''lv2.Items.Add("First entry")  
End Sub

when compiling this code, I get the error:

Program started.
main._appstart (java line: 55)
java.io.FileNotFoundException: ListViewLayout.bjl
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:206)
at anywheresoftware.b4j.objects.LayoutBuilder.loadLayout(LayoutBuilder.java:44)
at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:81)
at b4j.example.main._appstart(main.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.start(main.java:36)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)

how to solve this problem?
thank you in advance.
 
Works for me here, but the extension is lowercase (.fxml). Otherwise you could try specifying it.
Code: Copy
MainForm.RootPane.LoadLayout("ListViewLayout.FXML")
 
Upvote 0
Works for me here, but the extension is lowercase (.fxml). Otherwise you could try specifying it.
Code: Copy
MainForm.RootPane.LoadLayout("ListViewLayout.FXML")

The problem is that the file in the project (ListView Layout.FXML) have the extension .fxml - while the error: "java.io.FileNotFoundException: ListViewLayout.bjl" if the concern had a file with the extension .bjl
 
Upvote 0
I have projects that load fxml files without a problem.

Having done a quick test, it appears that Capital letters in the file extension could be causing problems. Try renaming the file with lowercase lettters.
 
Upvote 0
Are you sure you have added ListViewLayout.fxml on B4J Project Files Manager Window ?

I've tested on a project, deleting a fxml layout from Files Manager and by default, B4J tries to load layouts with a *.bjl extension (and show the error you posted seeking for a layout.bjl)

P.D:

bjl extension ---> layouts created on B4J Designer View (new way to create layouts on B4J)
fxml extension --> layouts created with Scene Builder (old way for creating layouts on B4J)
 
Upvote 0
Everything written above is consistent. After testing in small letters in the names of all working properly. Moreover mistakenly I called the directory using the string with a dot and an exclamation mark (.!) Which creates confusion when searching collections by B4J.
Thanks for taking the time cordial.
 
Upvote 0
Back
Top