B4J Question [JShell] How to run an EXE file created with B4JPackager11

Omar Moreno

Member
Licensed User
Longtime User
Hi.
With the JShell library, how should you run a program (JAR) that I have packaged with B4JPackager11 (EXE).

When I run the shell it throws this at me:

Success: false
ExitCode: -559038737
StdOut:
StdErr: org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "P1.exe" (in directory "F: \ PROGRAMMING \ B4J \ Packaged Program" ): CreateProcess error = 2, The system cannot find the specified file)

B4X:
Private Sh1 as Shell

Sh1.Encoding = "utf8"
Sh1.Initialize("Sh1", Aplicacion, Null)
Sh1.WorkingDirectory  =  TextField1.Text
Sh1.Run(-1)

Try with the attached files, P1 package it with B4JPackager11 and copy the path of P1.exe into Shell_P1, Shell_P1 will say it can't find P1.exe ....

How should I correctly run the Shell?


Thanks for the help.
 

Attachments

  • P1.zip
    2 KB · Views: 120
  • Shell.zip
    2.8 KB · Views: 120
  • Shell_P1.jar
    417.2 KB · Views: 107

Daestrum

Expert
Licensed User
Longtime User
Your path to the file seems to have a lot of extra spaces in it.
"F: \ PROGRAMMING \ B4J \ Packaged Program"
 
Upvote 0

Omar Moreno

Member
Licensed User
Longtime User
Thank you for responding, but I still deleted the spaces and still can't find the file...
upload_2019-10-19_13-57-24.png
 
Upvote 0

Omar Moreno

Member
Licensed User
Longtime User
Solved...

The only way to run the EXE is by adding full file path to the second parameter of Initialize

B4X:
Dim FullPath as String = File.Combine(TextFiel1.Text.Trim, Aplicacion)


Private Sh1 as Shell
Sh1.Encoding = "utf8"
Sh1.Initialize("Sh1", FullPath, Null)
Sh1.WorkingDirectory  =  TextField1.Text
Sh1.Run(-1)

I thought WorkingDirectory was used for jshell to search for the EXE.

Regards.
 
Upvote 0
Top