Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science A 13: 31/3. From.java to.exe - classpath - jar - resources - wrapper/launcher.

Similar presentations


Presentation on theme: "Computer Science A 13: 31/3. From.java to.exe - classpath - jar - resources - wrapper/launcher."— Presentation transcript:

1 Computer Science A 13: 31/3

2 From.java to.exe - classpath - jar - resources - wrapper/launcher

3 classpath Hvor java kigger efter klasser java –cp.;c:\mads\lib\java …main-class

4 Jar files Compress and collect several files in an archive (zip like) >jar cf HelloWorld.jar HelloWorld.class Run it: >java –cp HelloWorld.jar HelloWorld cp: classpath: HelloWorld.jar, Main class: HelloWorld

5 Access to resources BufferedImage image = JCanvas.loadImage(”pict.jpg”); Clip sound = JCanvas.loadClip(”sound.wav”); Find it in local directory – same as the class file. More robust approach:

6 Access to resources Access from a URL: BufferedImage image = JCanvas.loadImage( PlaySound.class.getResource(”pict.jpg”)); Clip sound = JCanvas.loadClip( PlaySound.class.getResource(”sound.wav”)); Find the main class (PlaySound), from that class create a URL of a ressource local to that class.

7 Jar files with resources Put class files an resources in a jar file: > jar cf PlaySound.jar *.class *.au > java –cp PlaySound.jar PlaySound Works if you access sounds using ”getResource”.

8 JSmooth Java program launcher: JSmooth: takes a.jar file, an.ico file and generates an exe file. The exe file locates a java runtime environment on the machine and run the jar-file

9 Running JSmooth Skeleton: Windowed wrapper Executable: Executable Binary: full name of exe file Executable Icon: full name of icon file Current Directory: full name of directory Application Main Class: main class Embedded jar: yes, jar file Menu: System: save as Menu: Project: compile

10 Jar to exe file PlaySound.exe can be played on other computers with jre (java runtime environment)


Download ppt "Computer Science A 13: 31/3. From.java to.exe - classpath - jar - resources - wrapper/launcher."

Similar presentations


Ads by Google