B4J Question Non-UI app how can I resatart (or call appstart)

ta1dr

Member
Licensed User
Hello All
my project is non-ui on raspberry pi 2
and 29.pin connect ground (trigger state-change) proces goto set-up procedure ...
when finish set-up I want to restart app or call appstart
can I do it ?
 

ta1dr

Member
Licensed User
I tried but give error

B4X:
About to restart: AsyncInput2
main._appstart (java line: 162)
java.lang.RuntimeException: java.io.IOException: Error while trying to restart the application
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:114)
    at anywheresoftware.b4a.BA$4.run(BA.java:196)
    at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
    at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
    at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
    at b4j.example.main._appstart(main.java:162)
    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:483)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at b4j.example.main.main(main.java:29)
Caused by: java.io.IOException: Error while trying to restart the application
    at com.ab.abcron.ABCron.Restar
tApplicationNONUI(ABCron.java:132)
    at b4j.example.main._set_up_statechange(main.java:731)
    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:483)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    ... 12 more
Caused by: java.lang.NullPointerException
    at com.ab.abcron.ABCron.RestartApplicationNONUI(ABCron.java:128)
    ... 18 more
Restarting: "/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/bin/java" -jar AsyncInput2
java.io.IOException: Cannot run program ""/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/bin/java"": error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
    at java.lang.Runtime.exec(Runtime.java:620)
    at java.lang.Runtime.exec(Runtime.java:450)
    at java.lang.Runtime.exec(Runtime.java:347)
    at com.ab.abcron.ABCron$2.run(ABCron.java:110)
Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:187)
    at java.lang.ProcessImpl.start(ProcessImpl.java:134)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1023)
    ... 4 more

problem this
Restarting: "/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/bin/java" -jar AsyncInput2
java.io.IOException: Cannot run program ""/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/bin/java"": error=2, No such fileor directory

java not this directory on Raspberry Pi
 
Upvote 0

alwaysbusy

Expert
Licensed User
1. What is the folder where your java is located? The folder you show above is what this line in the java library returns, surrounded with double quotes (maybe it is the double quotes that causes it on a non-windows system?):

B4X:
String java = System.getProperty("java.home") + "/bin/java";

2. do you use the oracle java? (not sure this trick works with openJDK)
 
Upvote 0

ta1dr

Member
Licensed User
1-) /usr/bin/java my java folder on raspberry pi (linux system) and jdk-8-linux-arm-vfp-hflt installed
2-)yes oracle...

I solved simple method used timer and timer_Tick... no restartapp just call state machine....

but abcron interesting I want to learn how can I use ?

Can I use without cron.Initialize(Me, "cron", 0, 0, "", "0 0/1 * 1/1 * ? *") or how the initilation without any time or timing
only Can I use cron.RestartApplicationNONUI

regadrs and thanks again...

BTW: my project in the office I am at home now...I can try all on monday...
 
Upvote 0
Top