Results 1 to 6 of 6
  1. #1
    vijay_404 is offline Member
    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    Default How to embed a .chm file in Executable jar file

    hi,

    I integrated a help file into to particular pacakage through IDE As Swings Application,and when executing the jar file following code identifies the particular .chm file at Runtime.

    public static List getClasseNamesInPackage(String jarName, String packageName)
    {
    ArrayList arrayList = new ArrayList ();
    packageName = packageName.replaceAll("\\." , "/");
    if (getJar)
    System.out.println("Jar " + jarName + " for " + packageName);
    try{
    JarInputStream jarFile = new JarInputStream(new FileInputStream (jarName));
    JarEntry jarEntry;
    while(true) {
    jarEntry=jarFile.getNextJarEntry ();
    if(jarEntry == null){
    break;
    }
    if((jarEntry.getName ().startsWith (packageName)) && (jarEntry.getName ().endsWith (".chm")) ) {
    String name=jarEntry.getName().toString();
    System.out.println("name:"+name);

    // java.lang.Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL "+executionPath+"/Prototype.jar!/"+jarEntry.getName());

    java.lang.Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL "+"c:\\dist\\Prototype\\Super_Home\\help\\helpfile .chm");


    but, the problem is i can't access the .chm file at the runtime while executing the jar file itself, and i am getting null pointer exception. how to solve this problem.pls...urgent

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,335
    Rep Power
    25

    Default

    i can't access the .chm file at the runtime
    Can you show the error message with its source line number indicating where the NPE occurs?
    Java Code:
    if(jarEntry == null){
    break;
    }
    if((jarEntry.getName ()
    These statements look like the code will exit the while loop when jarEntry IS NULL
    causing a NPE when the getName() method is called.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default

    I integrated a help file into to particular pacakage through IDE As Swings Application,and when executing the jar file following code identifies the particular .chm file at Runtime.
    Once the .CHM is inside the jar it isn't a file. If you need to launch it, you'll have to extract it first and write it to the filesystem.

    db

  4. #4
    vijay_404 is offline Member
    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    Default

    hi,
    Burke and norm Thank you for your great support.I am able to findout the .chm file name only at runtime through the following code.

    String name=jarEntry.getName().toString();
    System.out.println("name:"+name);

    But,the requirement is open that file at runtime when user action performed i write the following code.At runtime can't we open the file as .chm without extracting the jar file?..i need to be deploy like a jar file only at client machine.
    i am new to using .chm help file, how to give a file path as file system at runtime jar execution?.....

    if((jarEntry.getName ().startsWith (packageName)) && (jarEntry.getName ().endsWith (".chm")) ) {

    String name=jarEntry.getName().toString();
    System.out.println("name:"+name);
    String executionPath = System.getProperty("user.dir");
    java.lang.Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL "+executionPath+"/"+jarEntry.getName());
    }


    Thank you,
    vijay

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,335
    Rep Power
    25

    Default

    Did you see this from Darryl.Burke:
    Once the .CHM is inside the jar it isn't a file. If you need to launch it, you'll have to extract it first and write it to the filesystem.
    You'll have to open an output file and copy the .chm jarEntry to the file before issuing the exec() method call.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

Similar Threads

  1. Executable File.
    By BeeGee in forum Advanced Java
    Replies: 13
    Last Post: 05-25-2010, 12:35 PM
  2. Exporting to a executable JAR file
    By Drun in forum Eclipse
    Replies: 4
    Last Post: 03-27-2010, 03:16 PM
  3. how to embed .jar in an html or php file
    By clydedoris in forum AWT / Swing
    Replies: 0
    Last Post: 03-10-2010, 06:00 AM
  4. Executable Jar File Creation
    By Doctor Cactus in forum New To Java
    Replies: 7
    Last Post: 11-13-2008, 03:31 AM
  5. Generate an executable file
    By romina in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •