Including javahelp in a jar executable

Hi, ive just created an application and would like to include a javahelp with it, ive got it running off my local machine with the java helpset working too , but what im wondering is, is it possbile to include jhall.jar in the application jar so people who do not have javahelp installed can still view the helpsets ? and if so how do i point to it so that it imports it when the helpset is called upon.
here is my manifest file
Manifest-Version: 1.0
Class-Path: ./jhall.jar
Created-By: NetBeans IDE
Specified-By: studentbudget/StudentBudget.jarContent
Main-Class: studentbudget/StudentBudget

Hi, ive just created an application and would like to
include a javahelp with it, ive got it running off my
local machine with the java helpset working too , but
what im wondering is, is it possbile to include
jhall.jar in the application jar so people who do not
have javahelp installed can still view the helpsets ?
and if so how do i point to it so that it imports it
when the helpset is called upon.
Try this; - where 'help' is a dir in your jar.
     try
               URL hsURL = getClass().getResource( "help/myhelpset.hs" );
               hs = new HelpSet(null, hsURL);
               // found helpset, allow help
               HelpBroker hb = hs.createHelpBroker();
                         menuItemHelp.addActionListener(new CSH.DisplayHelpFromSource(hb));
               // add help functionality to main menu
               menuHelp.add(menuHelpHelp);
               menuHelp.addSeparator();
               menuHelp.add(menuHelpAbout);
               menuBar1.add(menuHelp);
               // add help functionality to toolbar
               toolBarImages.addSeparator();
               toolBarImages.add(buttonHelp);
          catch (Exception ee)
               JOptionPane.showMessageDialog( null, "Be aware that online help could not be loaded.");
               //System.out.println("HelpSet " + hs.getTitle() + " not found");
               // helpfile not found. disallow help

Similar Messages

  • Including a DLL in JAR file (Comm API)

    Writing a little app that interfaces with serial port device using the communications API and I'd like to bundle it into an executable JAR. JBuilder will create the JAR for me fine, but the issue is with the win32com.dll file thats part of the comms API. I need to include this, I don't think its possible to include as part of the executable, but otherwise the DLL needs to be in the windows\system folder. Could I include the dll as part of the JAR archive and then extract it upon runtime? If so how would I go about this?
    Any help much appreciated.

    There is another option. Native libraries need to reside within the java.library.path location. As it turns out, if you, at runtime, grab this property and ADD your own location to it, then set it back in to the System.setProperty() call, it will NOT work. The only way to do it is the -Djava.library.path value that tjmaven suggested.
    However, if you read up on how a native library is found, it uses the ClassLoader.loadLibrary() which calls the protected findLibrary() method. You can therefore extend ClassLoader to find a path yourself.
    One way is to extend URLClassLoader since it has the protection/security stuff AND the ability to look in .jar files for you. Your custom loader is created by a "launcher" class in your .jar file. First, your luancher uses getClass().getProtectionDomain().getCodeSource().getLocation() to get the absolute location of the .jar file its executing within. From there, you open the jar and look for your native library, extract it using the JAR api to a location of your choosing. Now, you instantiate the custom classloader and using this custom loader instance you load the rest of your classes. The main .jar file contains two classes, the launcher and the custom classloader, and contains the native library if you wish to do it this way. The custom classloader, you specify a URL[] of "classpath" entries. You bundle up the rest of your source in a second .jar file that you pass to the URL[] when creating the custom classloader. It will find all your classes in the 2nd jar no sweat. You can even "reload" these classes on the fly by recreating the custom classloader instance if you so wish to add a sort of "reload" feature.
    Now, in your custom classloader, you override the findLibrary() and return the SAME STRING PATH that you used to unjar your native files to. This way, when the JVM asks your custom loader to load the library at some path, you return the right path to find the native files in.
    I haven't verified that this works just yet, but I will soon. Primarily, my plugin engine over at www.platonos.org will support the ability to place native libraries in plugins, allowing you to effectively wrap a native library use as a plugin. Not yet working, but we'll soon have it in place.

  • Distribution of the javaHelp extension (jhall.jar) with application.

    Hello,
    I have been looking into a work around with regard to the fact that jhall.jar is not included in the JRE. As it has to be included in jre/lib/ext, it therefore needs to be shipped with the application.
    I have been looking at Java Web Start - I can't really make out exactly what it does - if anyone has deployed the javahelp extension with their app, please would you tell me how to go about it? Is Java Web Start the best way? If so, how does it work in simple steps?
    I really need a solution to this - any help would be greatly appreciated......:
    Thanks in advance,
    Clodagh

    Hello Clodagh,
    there are several ways of distributing jhall.jar. An alternative of placing it in jre/lib/ext is to put it in the directory where the application is located, that is using jhall.jar.
    Although others might do it differently, I am using Web Start to distribute jhall.jar. I you have Web Start installed you cann see a working example at http://www.lightdev.com/template.php4?id=3 (click on the link that says 'Read the tutorial online' or use the following link directly http://www.lightdev.com/shtm_hlp.jnlp)
    The help set that is viewed with this link remains on the server. Web Start only instally a tiny reader application in Java (4 KB) and the JavaHelp extension (jhall.jar) in the same directory on the client. It then starts the reader with the help set (on the server) as a parameter.
    To set up something similar, you need to create two .jnlp files, one for the reader app and for jhall.jar. The .jnlp file for the reader app refers to the one for jhall.jar. When it is started by Web Start, above mentioned parts are installed and started, i.e. the help set is displayed in the typical viewer of JavaHelp.
    HTH
    Ulrich

  • JAR Executable works in netbeans but not under Dos?

    Hi all,
    I have created a jar executable and it works fine in netbeans(it was not created in netbeans) but I can't get it to run on the command line. If I type java ClassName.MainClass it will run but not using the command java JarFile.jar or java -jar JarFile.jar
    Any help would be most appreciated.

    When creating the manifest file did you add a carriage return at the end of the manifest? e.g.
    Main-Class:Hello.class
    (carriage return here on new line)
    I think it runs into problems if you dont add a carriage return ( a new blank line after manifest).
    Hope this helps
    Riz

  • How to get a file in the same dir with the jar-executable

    Hi,
    I need to read/write a file that exists in the same directory with the jar-executable. How can i do that? I think that when i specify no path for the file, the file has to be in current path. (Is that right?)
    Note: I do not know in which directory the jar and the file are.
    Thanx in advance

    Hi,
    I need to read/write a file that exists in the same
    directory with the jar-executable. How can i do that?
    I think that when i specify no path for the file, the
    file has to be in current path. (Is that right?)
    Note: I do not know in which directory the jar and
    the file are.
    Thanx in advance
    When you specify no path for the file, the file has to be in the directory where the virtual machine was started. ( the directory the java command was invoked in .)
    If you can't control the directory in which the vm is started, but you know the name of the .jar file you can do the following. This trick takes advantage of the fact that if you are using classes in a jar file, the name of the jar file must be in your classpath.
    public static String getPathOfJar( String nameOfJar )
    throws Exception
    StringTokenizer st = new StringTokenizer(
    System.getProperty( "java.class.path" ) ,
              System.getProperty( "path.separator" ) );
    String jarfile = "";
    while ( st.hasMoreTokens() )     
    String token = st.nextToken();
    if ( token.indexOf( nameOfJar ) > -1 )
    jarfile = token;
    break;
    if ( jarfile.equals("") ) throw new Exception( "Jar not found in classpath" );
    String path = jarfile.substring( 0 , jarfile.indexOf( nameOfJar ) );
    return path;
    //To open a file in the same directory as the sun archive tools.jar
    File f = new File( getPathofJar( "tools.jar" ) + "someFile.txt" );

  • Sending Command Line Arguments to Jar Executable

    Hi All
    I wish to send Command Line Arguments to Jar Executable.
    i.e. before I Jar'd my program, I would do the following
    public class CmdLnArgmntExp {
    public static void main(String[] args) {
    System.out.println("d");
    for (int i = 0; i < args.length; i++)
    System.out.println(args);
    Running the program in Console.
    Java CmdLnArgmntExp arg1 arg2 arg3 arg4Output:
    arg1
    arg2
    arg3
    arg4
    How would I do this to a Jar executable, hope that made sense
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    java -jar executable-jar-file-containing-class-CmdLnArgmntExp.jar arg1 arg2 arg3 arg4

  • Jar executable issue after jvm update

    I created a small demo application and bundled my classes and media files in a jar executable file. Everything was fine until I updated J2SE from 1.5.0 to 1.6.0_01.
    The application now starts, gets its input normally but soon after hangs, and the Swing GUI doesn't show up anymore.
    The jar file contains 4 packages (one of them contains the main class) and this simple manifest file:
    Main-Class: myapp.myAppLauncher
    Classpath: .\myapp.jar
    I created the jar as follows:
    jar cvfm gdv.jar Manifest.txt myapp mypackage2 mypackage3 mypackage4
    I recompiled the source before creating the jar archive, and if I launch the application from the console I see no difference from before. The problem is only for the jar version.

    Manually download and install the Java 4 update http://www.apple.com/downloads/macosx/apple/application_updates/javaformacosx105 update4.html, and Safari 4.0.1 http://www.apple.com/safari/download/ Run Software update, install anything that pop up, repair permissions, and restart. That should fix your problem.

  • [svn] 3140: Modifying build. xml to include templates in the jar from the new location.

    Revision: 3140
    Author: [email protected]
    Date: 2008-09-08 09:04:17 -0700 (Mon, 08 Sep 2008)
    Log Message:
    Modifying build.xml to include templates in the jar from the new location.
    Modified Paths:
    flex/sdk/trunk/modules/antTasks/build.xml

    Don't be so impatient and don't multipost! I've deleted your other thread about the same topic.

  • How do I put my jar executables into a cab file to create a setup/install?

    I want to create a setup program for installing my jar executable. I've seen ones that create cab files with a setup.exe program and would like to do the same. Any suggestions?

    Well, JARs generally don't have support files. That's the whole idea. A JAR is designed to be a stand alone application. You don't really need to install it, for that matter. I just thought you might be wanted shortcuts or something.
    Actually, there is some way to install Java programs through Java Web Start, if you want to check that out. I don't know anything about it, though.

  • Double clicking jar executables

    Hi everyone
    I know that this topic has been discussed before - but I have scanned all discussions, and the problem hasn't been solved yet. There have been some good suggestions, but no definitive solution provided.
    I have a jar executable supplied to me by a commercial software company. The application is packaged in a jar file. I have checked that the manifest has the correct Main-Class association in it. I can install the jar on some Win 2000 copmuters and it executes fine by just double clicking on the jar file. On my laptop which also has Win 2000 OS it simply refuses to execute. The very frustrating JVM Launcher error message "Could not find main class. Program will exit." is displayed.
    The only way that I have found to get around it is to put a batch file in the same directory as the jar file containing "start /MAX javaw -jar "C:\Program Files\EqWave\eqwave181\eqwave.jar"" and execute this batch file from a shortcut placed on the desktop. Not a very good work-round - but at least it works.
    What I can't figure out is why the jar will work when double clicked on some computers, but not on my laptop. Obviously it has something to do with my laptop setup.I have reinstalled the latest jre-1_5_0-windows-i586.exe, but it still won't work.
    Please, please, pretty please - what am I doing wrong?????
    Cheers
    Mike T

    On your laptop the file association could be wrong : check if the file association with .jar is "javaw -jar" and not only "javaw".
    It looks like the "-jar" option is missing in the command field of your file association...
    On my Windows 2000 computer, the file association for .jar is :
    "C:\Program Files\Java\j2re1.4.1\bin\javaw.exe" -jar "%1" %*Modify your file association and I bet it will be better.

  • How to run a Jar executable with non standard JVM memory settings

    Hi,
    I have a jar-executable that needs more memory than the JVM uses by default.
    The application works with:
    java -Xms128M -Xmx256M myapp
    How can the jar know that it need to start like this?
    I found a solution here http://forum.java.sun.com/thread.jsp?forum=32&thread=188484 , but i don't want to do this with a shortcut.
    Is there anyway to do this?
    Thanx in advance.

    Well i'll do that:
    public class launch
      public static String getJarPath()
        String path="";
        try
          StringTokenizer st = new StringTokenizer(System.getProperty( "java.class.path" ) ,System.getProperty( "path.separator" ) );
          String jarfile = "";
          while ( st.hasMoreTokens() )
            String token = st.nextToken();
            if ( token.indexOf("launch.jar") > -1 )
               jarfile = token;
               break;
          if ( jarfile.equals("") ) throw new Exception( "Jar not found in classpath" );
          path = jarfile.substring( 0 , jarfile.indexOf("launch.jar"));
       catch (Exception e)
        new AlertWin(e.toString());
       finally
        return path;
      public static void main(String[] args)
        try
          String path=launch.getJarPath();
          Runtime.getRuntime().exec("javaw -Xms128M -Xmx256M -jar " + path + "toBeExecuted.jar");
        catch(IOException e)
          new AlertWin(e.toString());
    }The launch.jar has to be in the same dir with the toBeExecuted.jar. (ofcourse that could change and the code is much simpler).

  • How to install a jar executable as a Win XP pro NT Service

    hi folks.
    Got a .jar file (compiled it in JBuilder, archived it as "Application" it executes by double clicking it. It works by scheduling it through schdule tasks...
    However I would like to run the JAR executable as a Windows Service (Win XP Pro). Is this possible in java?
    I have done similar thing in .NET C#/vb.net but service creation/processing is written within the code. All you do is go to dos prompt and type net start ... etc.
    How can I do the same in java?
    Please assist.

    Got a .jar file (compiled it in JBuilder, archived it
    as "Application" it executes by double clicking it.
    It works by scheduling it through schdule tasks...
    However I would like to run the JAR executable as a
    Windows Service (Win XP Pro). Is this possible in
    java?It might be possible, but knowing anything about OS specific stuff is not what Java is intended for. There is a Runtime.exec() method provided for any OS - specific stuff.

  • Export jdeveloper as jar executable file

    hello, I have a simple application developed using jdeveloper which access an oracle database and retrieve data. I would like to export this application as jar executable file. how can I do this using jdeveloper.
    Best regards

    Add a manifest file that identifies the main class. If you have questions on how to do that using your IDE, I suggest you hit 'F1' or visit a forum that deals with that IDE.

  • Including images in jar executable files. Using images in jar files.

    Does anybody know what is the reason of my problem??
    I created a package called test in my eclipse env. and in that package I placed folder named graph in which there is a file Help.png.
    Here is all the code I run in eclipse and it runs properly. When I create a jar file (using eclipse wizard) to execute without eclipse it can not execute and shows nothing (process starts and I have to kill it by myself in OS). Maybe there is some mistake with making jar... I do not know
    So let someone try tu run my class or build jar file and try to execute and share his observations (solutions) ??
    package test;
    import java.awt.Toolkit;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.UIManager;
    public class TestWindow extends JFrame {
         private JButton jButton1 = new JButton(new JARImage().getImage("Help.png"));
         public TestWindow() {
              this.getContentPane().add(jButton1);
              this.validate();
              this.setVisible(true);
         private class JARImage {
              protected ImageIcon getImage(String imageName) {
                   ImageIcon image = new ImageIcon();
                   try {
                        image.setImage((Toolkit.getDefaultToolkit().getImage(getClass()
                                  .getResource("graph/" + imageName))));
                   } catch (Exception ex) {
                        System.out.println("Image Error: " + ex);
                        ex.printStackTrace();
                   return image;
         public static void main(String[] args) {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (Exception e) {
                   e.printStackTrace();
              new TestWindow();
    }

    Uncaught error fetching image:
    java.lang.NullPointerException
         at sun.awt.image.URLImageSource.getConnection(Unknown Source)
         at sun.awt.image.URLImageSource.getDecoder(Unknown Source)
         at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
         at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
         at sun.awt.image.ImageFetcher.run(Unknown Source)

  • Include command line args in executable jar?

    Hello all,
    I'm trying to package up some software which takes 2 command line args to run (for example, java -jar prog.jar FooBar 3.14159). I'm using a utility called Jar2Exe to wrap it up into an exe (still needs JRE to run, but it's nicer packaging for distribution).
    My question is, how can I included command line arguments in the jar? Or can I? Or, are there any exe-wrapping utilities out there that will allow me to accomplish this?
    Thanks,
    -Thok

    Thok wrote:
    Hello all,
    I'm trying to package up some software which takes 2 command line args to run (for example, java -jar prog.jar FooBar 3.14159). I'm using a utility called Jar2Exe to wrap it up into an exe (still needs JRE to run, but it's nicer packaging for distribution).
    My question is, how can I included command line arguments in the jar? Or can I? Or, are there any exe-wrapping utilities out there that will allow me to accomplish this?
    Thanks,
    -ThokOkay, did some more research... It appears you can't specify command line options in a jar, but if you package it into an exe, you can--depending on what utility you use to wrap it, that is. I downloaded a free one (Launch4j) and it does the trick.
    -Thok

Maybe you are looking for