1 / 10

Computer Science A 13: 31/3

Computer Science A 13: 31/3. CS A. From .java to .exe. - classpath - jar - resources - wrapper/launcher. classpath. Hvor java kigger efter klasser java –cp .;c:madslibjava …main-class. Jar files. Compress and collect several files in an archive (zip like)

breena
Download Presentation

Computer Science A 13: 31/3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Science A 13: 31/3 CS A

  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)

More Related