IncludeBinary for creating EXE out of Java Jar files

Share your advanced PureBasic knowledge/code with the community.
Leo
User
User
Posts: 21
Joined: Sat Aug 02, 2003 8:48 pm
Location: Netherlands, Wijk bij Duurstede

IncludeBinary for creating EXE out of Java Jar files

Post by Leo »

Code updated for 5.20+

Writing Java means often multiple Jar files and a batchfile to start the
Java program. Multiple files cause version control. To eliminate this problem you can easily convert these files to one executable with help of a small Purebasic Program using the IncludeBinary command.

Code: Select all

Procedure LoadJARs()
  If CreateFile(1, "demo.jar")
    WriteData(1, ?demo, ?demo_end-?demo)
    CloseFile(1)
  EndIf
  
  If CreateFile(1, "thinlet.jar")
    WriteData(1, ?thinlet, ?thinlet_end-?thinlet)
    CloseFile(1)
  EndIf
EndProcedure

LoadJARs()
RunProgram("javaw","-jar demo.jar","",3)
DeleteFile("demo.jar")
DeleteFile("thinlet.jar")

DataSection
demo:
  IncludeBinary "demo.jar"
demo_end:

thinlet:
  IncludeBinary "thinlet.jar"
thinlet_end:
EndDataSection
For the Jar files I used the demo of the Thinlet GUI, that can be found at
http://thinlet.sourceforge.net