Can't launch the app with batch file[SOLVED]

Having problems with building or using the JCEF Java binding? Ask your questions here.

Can't launch the app with batch file[SOLVED]

Postby micrikit » Fri Jun 17, 2022 12:06 am

HI,
I made a Java application with JCEF.
It can be launched with Eclipse, but launched by batch file I made, always return exception like below:
Code: Select all
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Program Files\Java\jdk1.8.0_121\jre\bin\jawt.dll: Can't find dependent libraries
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1845)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1122)
        at org.cef.SystemBootstrap$1.loadLibrary(SystemBootstrap.java:24)
        at org.cef.SystemBootstrap.loadLibrary(SystemBootstrap.java:36)
        at org.cef.CefApp.<init>(CefApp.java:144)
        at org.cef.CefApp.getInstance(CefApp.java:221)
        at org.cef.CefApp.getInstance(CefApp.java:208)
        at jcef.Jcef.<init>(Jcef.java:75)
        at Main.exec(Main.java:15)
        at Main.main(Main.java:7)


and here is my bat file code:
Code: Select all
java -jar TEST_JCEF.jar
pause


and how to made the jar from my program:
1.right click program
2.export
3.select make runnable jar
4.select "Package required libraries into generated JAR" and finish

Maybe something is wrong in my buildpath?
Attachments
package.png
package.png (38.17 KiB) Viewed 13082 times
Last edited by micrikit on Fri Jun 17, 2022 8:54 pm, edited 1 time in total.
micrikit
Techie
 
Posts: 14
Joined: Tue Jun 14, 2022 2:10 am

Re: Can't launch the app with batch file

Postby magreenblatt » Fri Jun 17, 2022 2:53 am

You need to pass additional arguments in the batch file, and have a specific directory structure. See the binary distribution for an example.
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: Can't launch the app with batch file

Postby micrikit » Fri Jun 17, 2022 5:15 am

magreenblatt wrote:You need to pass additional arguments in the batch file, and have a specific directory structure. See the binary distribution for an example.


Thank you for your reply.
Copy binary distribution , change bin's file and recode run.bat like below:
Code: Select all
java -cp "./bin;./bin/*" -Djava.library.path=./bin/lib/win64 frame.Main


Still same Exception...
But the app , I made for test and it's so simple program , can be launch without Exception.
The one I want to launch and this simple one , there is no difference in structure or batch file code.
Why do I get Exception with the one and not the other...
Attachments
err.png
exception
err.png (27.33 KiB) Viewed 13070 times
micrikit
Techie
 
Posts: 14
Joined: Tue Jun 14, 2022 2:10 am

Re: Can't launch the app with batch file

Postby magreenblatt » Fri Jun 17, 2022 5:26 am

Are the JRE binary directories in your PATH? If not, try adding them.
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: Can't launch the app with batch file[SOLVED]

Postby micrikit » Fri Jun 17, 2022 8:53 pm

magreenblatt wrote:Are the JRE binary directories in your PATH? If not, try adding them.


It's not in PATH, so put in it then worked!!!
I don't know why the test app working without editing PATH , but not care anymore :D
Just in case someone experience same situation, here is my last batch code :
Code: Select all
set local
SET PATH="%PATH%;%~dp0\jdk1.8.0_121\bin;%~dp0\jdk1.8.0_121\jre\bin;"
".\jdk1.8.0_121\bin\java.exe" -cp ".\bin;.\bin\*;" -Djava.library.path=.\bin\lib\win64 frame.Main
pause

In my case , I packed JDK folder in my app's folder together cause I send this app to my customer so write the code like this,
but only launch app in local , write path to JRE binary directories in System PATH is enough.
Anyway , Thank you magreenblatt !!!
micrikit
Techie
 
Posts: 14
Joined: Tue Jun 14, 2022 2:10 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 18 guests