Classpath inside a JAR file...

Hi there,
I have recently learned that I cannot use my JDBC driver JAR file from within another JAR file. So now I have two JAR files........my application and associated files in one and the JDBC driver in the other.
This gives me......
gatekeeper.jar
ojdbc14.jar
My problem is, when running the application I get an exception stating that it cannot load the Oracle driver. I'm assuming that this is because it cannot find the JDBC JAR file from within the manifest Class-Path.
My manifest is this: -
Main-Class: GateKeeper
Class-Path: ojdbc14.jar commonfiles images
This includes my commonfiles package (all classes) and my images directory. All these things are included. I'm trying to run the gatekeeper JAR file from the same directory as the JDBC driver JAR file.
I've tried: -
Class-Path: ojdbc14.jar commonfiles images
Class-Path: .\ojdbc14.jar commonfiles images
Class-Path: ..\ojdbc14.jar commonfiles images
None of these things help. Obviously I could just specify the JDBC JAR file when running the application using: -
java -cp ojdbc14.jar -jar gatekeeper.jar
....but I want to have the user just run it without having to know about the classpath.....i.e.
java -jar gatekeeper.jar
DrClap said (and I quote) "In the same directory as your main JAR file is easiest, but at any rate the Class-Path entry in your manifest should include the relative path of the driver jar."
...Isn't the relative path to the JAR file outside the JAR this?
.\ojdbc14.jar
Basically, to recap....from within my JAR application file I want to add to the classpath in the manifest file the JAR file that is outside the application JAR file in the same directory. Helpy?
...I'd offer dukes to you fine folks, but I've only got two left. Since I'm such a newbie, I'm not likely to get any more inthe near future, so I'm saving them for a raining day. :) I hope I can get a little charity without resorting to duke bribary. :)

Hmmm...still not joy. This is the exception I'm getting with the stacktrace.
C:\Java\deployment\GateKeeper\JarFile>C:\j2sdk1.4.2_03\bin\java -jar gatekeeper.jar
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at commonfiles.OracleDataConnection.<init>(OracleDataConnection.java:26)
at GateKeeperFrame$MainAction.actionPerformed(GateKeeperFrame.java:429)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
at java.awt.Component.processMouseEvent(Component.java:5100)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
My gatekeeper.jar file contains the following files: -
C:\Java\deployment\GateKeeper\JarFile>jar -tvf gatekeeper.jar
0 Wed May 19 19:06:42 BST 2004 META-INF/
95 Wed May 19 19:06:42 BST 2004 META-INF/MANIFEST.MF
0 Wed May 19 19:06:38 BST 2004 commonfiles/
1185 Mon Apr 26 22:24:30 BST 2004 commonfiles/ErrorDialog.class
1319 Fri Apr 16 10:50:28 BST 2004 commonfiles/ErrorItem.class
1381 Tue Apr 27 19:53:32 BST 2004 commonfiles/ErrorList.class
4207 Mon May 17 12:58:40 BST 2004 commonfiles/FileIO.class
1371 Fri May 14 12:00:38 BST 2004 commonfiles/Input.class
1655 Fri Apr 23 15:13:58 BST 2004 commonfiles/OracleConnectionDetails.class
6653 Fri May 14 14:34:58 BST 2004 commonfiles/OracleDataConnection.class
8612 Fri May 14 15:06:02 BST 2004 commonfiles/Utility.class
0 Mon May 17 19:56:40 BST 2004 images/
116 Wed Apr 21 10:19:50 BST 2004 images/Connect.gif
119 Wed Apr 21 10:19:28 BST 2004 images/Disconnect.gif
117 Wed Apr 21 10:16:24 BST 2004 images/Exit.gif
1024 Mon May 10 14:38:28 BST 2004 GateKeeper.class
186 Wed May 12 11:08:44 BST 2004 GateKeeperFrame$1.class
5300 Mon May 17 14:38:28 BST 2004 GateKeeperFrame$MainAction.class
1740 Fri May 14 15:21:20 BST 2004 GateKeeperFrame$MainButtonListener.class
11034 Mon May 17 11:07:30 BST 2004 GateKeeperFrame.class
898 Wed Apr 28 22:10:56 BST 2004 LoginFrame$DataSource.class
6938 Wed Apr 28 22:10:56 BST 2004 LoginFrame.class
3261 Fri May 14 12:22:28 BST 2004 UsersDataModel.class
My manifest file for gatekeeper.jar file contains this: -
Main-Class: GateKeeper
Class-Path: ojdbc14.jar
And the directory where I'm running the gatekeeper.jar file contains this: -
gatekeeper.jar
ojdbc14.jar
which I'm running using: -
java -jar gatekeeper.jar
Thanks for your help guys. And no, I don't have a newline at the end of the Class-Path entry in the manifest.

Similar Messages

  • How can i get the path to config folder placed inside the jar file?

    Hi i have developed an RCP application using eclipse.
    In my application config directory is there.
    When i export my RCP application as JNLP Project the jar file is created which contains config folder inside it.
    When i download the application using java web start , how can i get the path to config folder placed inside the jar file?
    Will the config folder exists in local cache in my system?
    Help needed.
    -Deepak

    -- This works in CS6:
    tell application "Adobe InDesign CS6"
      set myDocument to active document
      set selectedRectangles to selection of myDocument
      set theGraphicsLink to file path of item link of (graphic 1 of (item 1 of selectedRectangles))
    --> "Macintosh HD:folder/folder/filename.tif"
    end tell

  • Call class inside a jar file??

    Hello group,
    I have a class with a main mathod and this class is inside a .jar file. This jar file reside under my
    web-inf\lib or class-path directory in my application at Weblogic Server.
    How can I call this class by command line?
    I have to create a cliente to do it?
    Is it possible? I´m having problems because the weblogic server is using the jar file at the same time that I trying use it calling by command line.
    Where can I find more information?
    Message was edited by:
    Denimar

    Authcloud9981 wrote:
    Hi I have an executible JAR file that I can call from command line by using the command - "java -jar file.jar".
    Is there a way for me to call this JAR file inside a Java class in another Java Program?There can be more going on in a jar than just as a container for classes.
    The manifest defines the behavior. So to replicate the behavior you must do exactly that.
    As an example of that.
    [http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html#download]
    Additionally by running it in your application you must consider what the scope of that is. If you just load the classes directly then they will be in the system class loader and thus cannot be unloaded. Using a class loader solves that.

  • Include and call an .exe file inside my jar file

    Hi.
    I want to include an exe file and call it inside my jar file. this is the code.
    InputStream is = getClass().getResourceAsStream("/native/my.exe");
              int[] line = new int[is.available()];
              File myFile = File.createTempFile("my","exe");
              myFile.deleteOnExit();
              myFile.setExecutable(true);
              FileOutputStream out = new FileOutputStream(myFile.getAbsolutePath());
              int i = 0;
              int c;
              while((c=is.read()) != -1){
                   line=c;
                   i++;
              is.close();
              for(int j= 0;j<line.length;j++)
                   out.write(line[j]);
              out.close();
    So i store it in my temp folder. Than i run
    String myFileLocation = myFile.getAbsolutePath();
    p = rt.exec(myFileLocation);
    Everything goes fine, but the behaviour of the .exe file is not the same. I mean when i run the commands
    PrintWriter writer = new PrintWriter(p.getoutputStream());
    writer.println("command");
    the behaviour is not the same. What goes wrong.

    But to load the xml file I need to create a File objectIf this is true then you will not be able to load the XML file, since a jar entry is not a File object and cannot be represented as one.
    However if you get rid of whatever it is that loads your XML file and replace it by more standard JAXP processing, you should be able to parse an InputStream that reads from the jar entry. You know how to get that so it should not be a problem.

  • A .dll inside a .jar file

    Hello,
    I want to place a .dll inside a .jar file ? It's possible, What is the library.path setting: the jar file or the path where the dll is put is in the jar file; and the argument of the System.loadLibrary?
    Thank for all

    Hello,
    I want to place a .dll inside a .jar file ? It's
    possible,Of course, you can put any type of file you want into a jar file.
    What is the library.path setting: the jar
    file or the path where the dll is put is in the jar
    file; and the argument of the System.loadLibrary?You cannot do a System.load() or System.loadLibrary() on something in a jar file.
    You have to first extract the dll to the filesystem. Then if you put it in the library path you can use System.loadLibrary(). But I think it is easier to use System.load() as you know the complete path to where you put the dll and can just supply that to System.load().

  • Java Files inside the jar file cannot be read or accessed through Eclpse

    The Java File inside the jar file of the eclipse cannot be accessed through the Eclipse . It shows error for the modules in the jar file .
    But when compiled with adding the jar files to the class path the compilation is successful .
    How can i browse through the files in the jar like going into the function definition .
    TIA ,
    Imran

    Open MPlayer OSX and show the playlist (command-shift-p) then drag the file into the playlist. Click the file in the playlist and click the "i"nfo button. What does it list for file, video and audio format?
    Not all of the codecs used in avi and wmv files are available for OS X so I'm guessing your file happens to be using one that isn't...

  • I am having Html help files inside my Jar file

    Dear Friends;
    i am having Html help files inside my Jar file.
    how will open the html file using Java Help.
    Thank u

    http://java.sun.com/products/javahelp/reference/docs/index.html

  • Can i load a class in subdirectoy  inside a jar file using applet tag?

    hi every one.. thank you for reading ... i am really in dire need for the solution..
    my problem is that i have a jar file contianing a package which inturn contains my applet class...
    i am trying to access this applet class using a applet tag in html file. this html file is in same directory as the jar file. i am having no problems in windows but when i am doing this in linux apache server i was getting class not found exception. (already checked the file permissions). and when i am successful when using simple package directory instead of jar file . so gist of my quesition is "can i load a class in subdirectoy inside a jar file using applet tag in a html file"?

    When you tested in Windows were you using Internet Explorer? On Linux you will be using a different browser, usually Mozilla of some version, or Firefox. Note that the HTML tags for applets will be different between the browsers if you are using the object tag. Principally the classid value for the object tag will differ between Firefox and Internet Explorer.

  • How to read, write file inside the JAR file?

    Hi all,
    I want to read the file inside the jar file, use following method:
    File file = new File("filename");
    It works if not in JAR file, but it doesn't work if it's in a JAR file.
    I found someone had the same problem, but no reply.
    http://forum.java.sun.com/thread.jsp?forum=22&thread=180618
    Can you help me ? I have tried this for all night !
    Thanks in advance
    Leo

    If you want to read a file from the JAR file that the
    application is packaged in (rather than a separate
    external JAR file) you do it like this ...
    InputStream is =
    ClassLoader.getSystemResourceAsStream("filename");Better to use
    this.getClass().getClassLoader().getResourceAsStream();
    From a class near to where the data is. This deals with multiple classloaders properly.

  • Classpath Issue - but JAR file is in the classpath

    I'm having an issue getting a JAVA Application Client to run and would welcome any suggestions or input to resolve this problem. I'm not a developer, just the builder/deployer of the applications. There are two developers looking at this problem too, but they are stumped too.
    It complains that it can't find sun/jdbc/rowset/CachedRowSet, which is contained in the rowset.jar - which is in the classpath. I've put all the supporting information below, if you need additional information please let me know and I'll provide it.
    ***** ERRORS FROM RUNNING SCRIPT BELOW *****
    *** NOT Using Verbose: ***
    Exception in thread "main" java.lang.NoClassDefFoundError: sun/jdbc/rowset/CachedRowSet
    *** Using Verbose (only included the output with the error): ***
    [Loading superclasses of com/actuate/schemas/SubmitJobResponse]
    [Loaded java.sql.SQLException from /usr/java130/jre/lib/rt.jar]
    [Loading superclasses of java/sql/SQLException]
    [Signaling in VM: java/lang/NoClassDefFoundError, message: sun/jdbc/rowset/CachedRowSet]
    Exception in thread "main" java.lang.NoClassDefFoundError: sun/jdbc/rowset/CachedRowSet[Loaded sun.i
    o.UnknownCharacterException from /usr/java130/jre/lib/rt.jar]
    [Loading superclasses of sun/io/UnknownCharacterException]
    [Preparing sun/io/UnknownCharacterException]
    ***** SCRIPT TO RUN THE JAVA COMMAND *****
    #!/usr/bin/ksh
    LIBDIR="/actuate/Mace/lib"
    JAVA_CP=""
    MAIN_JAR="MaceEXT.jar"
    JAVA_PATH="/usr/java130/jre/bin"
    JAVA_HOME="/usr/java130/jre"
    JAVA_FULLVERSION=`$JAVA_PATH/java -fullversion`
    JAVA_EXE=${JAVA_HOME}/bin/java
    PATH=$JAVA_PATH:$PATH
    export PATH
    export JAVA_HOME
    JAVA_CP="${LIBDIR}/sljcx.jar"
    JAVA_CP="${LIBDIR}/sljc.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/rowset.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/wsdl4j.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/tt-bytecode.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/servlet.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/saaj.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/log4j-1.2.4.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/jaxrpc.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/commons-logging.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/axis.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/ivjejb35.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/j2ee.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/activation.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/mail.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/ns.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/xmlParserAPIs.jar":${JAVA_CP}
    JAVA_CP="${LIBDIR}/xercesImpl.jar":${JAVA_CP}
    JAVA_CP="$JAVA_HOME/lib/rt.jar":${JAVA_CP}
    echo ""
    echo "Classpath"
    echo $JAVA_CP
    echo ""
    echo "JAVA_Home"
    echo $JAVA_HOME
    echo ""
    echo "JAVA_EXE"
    echo $JAVA_EXE
    echo ""
    echo "JAVA_Path"
    echo $JAVA_PATH
    echo ""
    echo "JAVA FullVersion"
    echo $JAVA_FULLVERSION
    #$JAVA_EXE -cp $JAVA_CP -jar $MAIN_JAR -h dev -c adduser -u 000 -p ""
    $JAVA_EXE -verbose -cp $JAVA_CP -jar $MAIN_JAR -h dev -c adduser -u 000 -p ""
    ***** JAR -tvf OF ROWSET.JAR *****
    server105:/actuate/Mace/lib $ jar -tfv rowset.jar
    0 Tue Jun 13 19:45:42 EDT 2000 META-INF/
    66 Tue Jun 13 19:45:42 EDT 2000 META-INF/MANIFEST.MF
    0 Tue Jun 13 19:45:30 EDT 2000 sun/
    0 Tue Jun 13 19:45:30 EDT 2000 sun/jdbc/
    0 Tue Jun 13 19:45:42 EDT 2000 sun/jdbc/rowset/
    551 Tue Jun 13 19:45:30 EDT 2000 sun/jdbc/rowset/BaseRow.class
    9112 Tue Jun 13 19:45:32 EDT 2000 sun/jdbc/rowset/BaseRowSet.class
    35562 Tue Jun 13 19:45:36 EDT 2000 sun/jdbc/rowset/CachedRowSet.class
    597 Tue Jun 13 19:45:36 EDT 2000 sun/jdbc/rowset/ColInfo.class
    1290 Tue Jun 13 19:45:36 EDT 2000 sun/jdbc/rowset/InsertRow.class
    18442 Tue Jun 13 19:45:38 EDT 2000 sun/jdbc/rowset/JdbcRowSet.class
    2109 Tue Jun 13 19:45:38 EDT 2000 sun/jdbc/rowset/Row.class
    4489 Tue Jun 13 19:45:38 EDT 2000 sun/jdbc/rowset/RowSetMetaDataImpl.class
    4707 Tue Jun 13 19:45:38 EDT 2000 sun/jdbc/rowset/RowSetReaderImpl.class
    8270 Tue Jun 13 19:45:38 EDT 2000 sun/jdbc/rowset/RowSetWriterImpl.class
    4745 Tue Jun 13 19:45:40 EDT 2000 sun/jdbc/rowset/SQLInputImpl.class
    3287 Tue Jun 13 19:45:40 EDT 2000 sun/jdbc/rowset/SQLOutputImpl.class
    2326 Tue Jun 13 19:45:40 EDT 2000 sun/jdbc/rowset/SerialArray.class
    1560 Tue Jun 13 19:45:40 EDT 2000 sun/jdbc/rowset/SerialBlob.class
    1948 Tue Jun 13 19:45:40 EDT 2000 sun/jdbc/rowset/SerialClob.class
    592 Tue Jun 13 19:45:40 EDT 2000 sun/jdbc/rowset/SerialRef.class
    2419 Tue Jun 13 19:45:40 EDT 2000 sun/jdbc/rowset/SerialStruct.class
    1903 Tue Jun 13 19:45:40 EDT 2000 sun/jdbc/rowset/WebRowSet.class
    257 Tue Jun 13 19:45:40 EDT 2000 sun/jdbc/rowset/XmlReader.class
    15620 Tue Jun 13 19:45:40 EDT 2000 sun/jdbc/rowset/XmlReaderDocHandler.class
    2029 Tue Jun 13 19:45:40 EDT 2000 sun/jdbc/rowset/XmlReaderImpl.class
    258 Tue Jun 13 19:45:40 EDT 2000 sun/jdbc/rowset/XmlWriter.class
    9797 Tue Jun 13 19:45:42 EDT 2000 sun/jdbc/rowset/XmlWriterImpl.class
    ***** ECHO OF VARIABLES FROM SCRIPT *****
    Classpath
    /usr/java130/jre/lib/rt.jar:/actuate/Mace/lib/xercesImpl.jar:/actuate/Mace/lib/xmlParserAPIs.jar:/ac
    tuate/Mace/lib/ns.jar:/actuate/Mace/lib/mail.jar:/actuate/Mace/lib/activation.jar:/actuate/Mace/lib/
    j2ee.jar:/actuate/Mace/lib/ivjejb35.jar:/actuate/Mace/lib/axis.jar:/actuate/Mace/lib/commons-logging
    .jar:/actuate/Mace/lib/jaxrpc.jar:/actuate/Mace/lib/log4j-1.2.4.jar:/actuate/Mace/lib/saaj.jar:/actu
    ate/Mace/lib/servlet.jar:/actuate/Mace/lib/tt-bytecode.jar:/actuate/Mace/lib/wsdl4j.jar:/actuate/Mac
    e/lib/rowset.jar:/actuate/Mace/lib/sljc.jar:/actuate/Mace/lib/sljcx.jar
    JAVA_Home
    /usr/java130/jre
    JAVA_EXE
    /usr/java130/jre/bin/java
    JAVA_Path
    /usr/java130/jre/bin
    JAVA FullVersion
    java full version "J2RE 1.3.0 IBM build ca130-20020504"
    ***** DIRECTORY LISTING *****
    server105:/actuate/Mace $ ls -lat
    -rwxr-xr-x 1 actuate actuate 1673 Apr 04 09:11 go.sh
    -rw-r----- 1 actuate actuate 476699 Apr 03 12:37 MaceEXT.jar
    drwxr-xr-x 2 actuate actuate 4096 Apr 02 10:49 lib
    -rw-r----- 1 actuate actuate 1818 Mar 28 11:15 MaceConfig.xml
    server105:/actuate/Mace/lib $ ls -lat
    -rw-r----- 1 actuate actuate 32033 Apr 02 10:49 ivjejb35.jar
    -rw-r----- 1 actuate actuate 329096 Apr 02 10:49 j2ee.jar
    -rw-r----- 1 actuate actuate 374291 Apr 01 16:39 ns.jar
    -rw-r----- 1 actuate actuate 654326 Apr 01 16:31 sljc.jar
    -rw-r----- 1 actuate actuate 81987 Apr 01 16:31 sljcx.jar
    -rw-r----- 1 actuate actuate 54368 Mar 31 08:32 activation.jar
    -rw-r----- 1 actuate actuate 867459 Mar 31 08:32 axis.jar
    -rw-r----- 1 actuate actuate 24287 Mar 31 08:31 commons-logging.jar
    -rw-r----- 1 actuate actuate 32069 Mar 31 08:31 jaxrpc.jar
    -rw-r----- 1 actuate actuate 378778 Mar 31 08:31 log4j-1.2.4.jar
    -rw-r----- 1 actuate actuate 305414 Mar 31 08:31 mail.jar
    -rwxrwxrwx 1 actuate actuate 62388 Mar 31 08:31 rowset.jar
    -rw-r----- 1 actuate actuate 18468 Mar 31 08:31 saaj.jar
    -rw-r----- 1 actuate actuate 78350 Mar 31 08:31 servlet.jar
    -rw-r----- 1 actuate actuate 130773 Mar 31 08:31 tt-bytecode.jar
    -rw-r----- 1 actuate actuate 109356 Mar 31 08:31 wsdl4j.jar
    -rw-r----- 1 actuate actuate 933730 Mar 31 08:31 xercesImpl.jar
    -rw-r----- 1 actuate actuate 78440 Mar 31 08:31 xmlParserAPIs.jar

    All that script made my eyes glaze over, but it appears you are running your main class from an executable jar file. Is that correct? Executable jar files don't use the classpath. If you want them to refer to anything outside the executable jar, you have to put Class-Path entries in its manifest.

  • How to set the classpath for external .jar files after importing?

    Hi techs,
    How to set the classpath in WSAD5.1.2 after importing the .jar file to the WEB-INF/lib folder.
    urgent

    I got it.
    after importing the jar file to the perspective,we need to right click on project name, go to proprties,
    goto java build path,
    there we need to include the external jar files.

  • IconService and classpath in executable jar file

    I use JDIC project (https://jdic.dev.java.net/) and want to use its incubator project iconService as well - both of them in one project. When I run my program from within Eclipse 3.1 IDE, everything works.
    But if I export it to a jar file, the program does not run. I found out that Eclipse 3.1does not create the manifest file correclty. When using only JDIC, I wrote this line to the Manifest file and the exported jar worked:
    Class-Path: external_libs/jdic-0.9-bin-cross-platform/jdic.jarBut when I try to add also the other library - Iconservice to the classpath of the Manifest file like this:
    Class-Path: external_libs/jdic-0.9-bin-cross-platform/jdic.jar external_libs/Icon_service/jdic_icon.jar the console writes out these errors:
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at Frontend.Mainframe.getIcon
    Caused by: org.jdesktop.jdic.spi.ProviderException: Provider org.jdesktop.jdic.icons.impl.WinIconProvider  can not be found
    at ...
    I suppose that the program cannot find the needed "jdic_icon.dll" but I do not know how to set the path to a dll into classpath of manifest file.
    Can anyone help me?
    Thanx in advance.
    Lubos.

    [This is a cross-post of http://forum.java.sun.com/thread.jsp?forum=424&thread=453226]

  • How to read a file inside the JAR file

    Hi All,
    I want to save some preferences in a file called "preferences". I kept the preferences file under my java package.
    If i am running the code inside the NetBeans 6.9 IDE it's working file. But once i have created a JAR and try to run the application, it couldn't find the path.
    Please help me that how to resolve this issue. I don't want to save this preferences file outside of my JAR (i.e) within my java package.
    Here is the code,
    package mypackage;
    import java.io.BufferedReader;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.io.PrintWriter;
    public class ReadFile
        private void writeFile()
            try
                OutputStream out = new FileOutputStream(getClass().getClassLoader().getResource("mypackage/preferences").getPath().replace("%20", " "));
                PrintWriter writer = new PrintWriter(out);
                writer.println("Hello Java!");
                writer.close();
                out.close();
            catch (Exception ex)
                System.out.println(ex.getMessage());
        private void readFile()
            try
                FileInputStream fi = new FileInputStream(getClass().getClassLoader().getResource("mypackage/preferences").getPath().replace("%20", " "));
                BufferedReader br = new BufferedReader(new InputStreamReader(fi));
                System.out.println(br.readLine().trim());
                br.close();
                fi.close();
            catch (Exception ex)
                System.out.println(ex.getMessage());
        public static void main(String[] args)
            ReadFile read = new ReadFile();
            read.writeFile();
            read.readFile();
    }If i run the JAR, i get the following error message,
    {color:#ff0000}*file:\my jar path\jarname.jar!\mypackage\preferences (The filename, directoryname, or volume label syntax is incorrect)*{color}

    Thanks sabre150,
    sabre150 wrote:
    You cannot update a running jar file. I am sorry. I didn't know about it. Thanks to point out.
    There are two ways I approach this depending on my exact requirements -
    1) use the java.util.prefs.Preferences APII will try this one
    >
    2) if not already present I copy the preferences file from the jar to a known place. I use a directory in the user's home directory and normally make the directory name the program with a '.' prefix.
    One cannot access files in a jar file using the File API. One needs to use the getResource() or getResourceAsStream() methods on Class or ClassLoader.

  • How do i run a file that is inside a jar file?

    Hi all,
    Here's what I'm trying to do: on a Unix (Solaris) box, I have a shell script bundled in with my application in a jar file. All I want to do is run the shell script from inside my java app, but I'm having trouble doing so.
    If i try the following code:
    Process process = Runtime.getRuntime().exec("myproject/tools/scripts/myscript.sh");
    int exitVal = process.waitFor();I get the following error:
    java.io.IOException: myproject/tools/scripts/myscripts.sh: not found
            at java.lang.UNIXProcess.forkAndExec(Native Method)
            at java.lang.UNIXProcess.<init>(UNIXProcess.java:52)
            at java.lang.Runtime.execInternal(Native Method)So then I did some searching and tried something like :
         ClassLoader cl = this.getClass().getClassLoader();
         URL the_file = cl.getResource("myproject/tools/scripts/myscript.sh");
         Process process = Runtime.getRuntime().exec(the_file);
         int exitVal = process.waitFor();but i get this error:
    cannot resolve symbol
    symbol  : method exec (java.net.URL)
    location: class java.lang.Runtime
         Process process = Runtime.getRuntime().exec(the_file);So is that the right way i should be doing this? Should i convert the URL (the_file)
    to something else before passing to exec()?
    Any hints/help/suggestions would be greatly appreciated.
    Thanks.

    The trouble with your first attempt might be that your relative path to the shell script is not relative to where you think it is. You could try again with an absolute path to the script as a simple test. Assuming that works you can try a more permanent solution -- perhaps a startup script for the Java app that defines a base path or a Properties file.
    You are exactly right about the problem with your second try. The exec method in all its forms expects a String as the first argument, so the URL is not going to help much, assuming that the URL is in fact non-null.

  • Extracting and updating files inside a JAR file... from my code

    Hi.
    I need some help in the following:
    from my code, I need to search a JAR file, open it, unzipped it, then I need to search a xml and property files inside the JAR, after that I need to modify the files and finally, my code has to save the changes and update the JAR file. All that must be from my java code.
    How can I do that? I am trying to use Runtime.getRunTime().exec().... but I am not sure that it works. Besides, I don�t know what command to include in the exec() method. Is there any way to do that?
    Thanks

    The normal reason I see for this requirement is that people want to update a properties or data file. The approach I use it that I first look for the data file in a well defined location and if I find it I use it and update it as required. If I don't fine it I create it base on a template file read from the jar file using getResourceAsSrream().
    In this way I never have to update the jar file.

Maybe you are looking for

  • Nokia PC Suite 6.86.9.0 and change default path

    Hi, Does anybody know how to change the default paths for "File Manager", "Contacts" and "Messages"? When entering those parts of PC Suite it automatically tries to open C:\Program Files\Nokia\Nokia PC Suite 6 folder (installation folder) but in my c

  • Way to have this table format

    hi, experts, there are 2 dimensions and 3 facts (measures). two dimensions are Sales Team and SKU. Quantity is by SKU and Sales Team, Point is by SKU and Sales Team. but Expected Point is by Sales Team only. Variance is (Sum of Points) / Expected Poi

  • Time Based workflow not working

    Hi, I am facing issue in time based workflow. I designed a worflow with two actions. Wait action is the first action and second action is send email. For send email the from address is current user and TO is owner of the record. One thing I noticed i

  • Old hard drive crashed so replaced with a new one,phone is syncing but no pictures showing and no contacts have transfered,any ideas

    i have just replaced my hard drive,i have downloaded itunes and signed in,i connected my phone up it synced up but it is not showing any of my pictures and none of my contacts have transfered,any ideas,thanks dai.

  • BufferedReader doesn't read the whole file.

    Hi, I am reading a text file using this piece of code: BufferedReader in = new BufferedReader("C:\\ServerOut.txt"); String str; while((str = in.readLine()) != null) { System.out.println(str); }The problem is that not the whole file is being read. I d