Yup, a Jar question

i have really really tried to answer this question.
i searched the forums. i read the api.
so please, haha, please help.
i know jar questions dont typically get a warm reception.
I have a folder containing a couple folders and one jar file.
Images/
Data/
MyApp.jar
i cannot access the images in the Images folder.
im getting this error:
Resource not found: /Images/ToolBar/pic.gif
Uncaught error fetching image:
java.lang.NullPointerException
at sun.awt.image.URLImageSource.getConnection(URLImageSou
9)
at sun.awt.image.URLImageSource.getDecoder(URLImageSource
at sun.awt.image.InputStreamImageSource.doFetch(InputStre
rce.java:248)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
this is the code i use to load images:
String imgLocation = "Images/ToolBar/" + imageName + ".gif";
URL imageURL = MyClass.class.getResource(imgLocation);i also tried it with a "/" before "Images" in the code.
I tried adding the folder to the manifests classpath.
I also tried knocking on wood and counting sheep.

the way my computer is configured i never use "-cp . " when
running a java program.
it usually uses the present directory as the class path.
but i have looked into that (maybe im doing it wrong).
im running "java -jar MyApp.jar" from the command-line (in XP)
from the directory that holds the .jar and the Images/ folder.
i tried "java -cp . -jar..."
i also tried putting the class path in the manifest file but every\ytime
i did that i got "no class in main" error.
if C:\My\Program contains MyApp.jar and directory Images/
Class-Path: C:\My\Program\Images
didnt work
Class-Path: C:\My\Program ; C:\My\Program\Images
didnt work
i tried the / both directions
ive tried countless permutations of this.getclassloader / getclass blah blah also.
every thread gives the class loader as the answer but so far
nothing has worked.
its amazing how many times this question has been asked and
there usually isnt an answer.
im depressed, haha.

Similar Messages

  • Simple applet jar question

    I'm sure this is an easy question, but how do you access subdirectories in your applet's jar file?
    For instance the contents of MyApplet.jar jar would be:
    * META-INF
    * images
    * net
    Say the main class is MyApplet.class in net/mydomain/myproject
    How in the main class would I get at images/MyImage.jpg?
    Obviously I did not get this code to work:
    ImageIcon upIcon = new ImageIcon("images/MyImage.jpg");
    Thanks alot!

    Actually now I am using:
    ImageIcon upIcon = new ImageIcon(MyApplet.class.getResource("/images/MyImage.jpg"));
    This way the 'absolute' resource is found (becuase the resource name starts with a '/').
    This seems to be the best way to do it.

  • Basic JAR Question

    Hello,
    I hate to ask such a simple question, but I'd like to get confirmation from people who know.
    It is possible to package non-EJBs into a deployed JAR containing EJBs, isn't it? I have heard that you cannot mix a non-EJB class into a JAR that contains EJBs, but my interpretation of the literature I've found about packaging EJBs seems to indicate otherwise.
    Basically, it looks like you would want to (or need to in some cases) package any class that an EJB depends upon through inheritance or through another association (e.g. a custom user Exception class that and EJB might throw) into the same JAR file.
    Please reply and set me straight on this. Thanks in advance.
    Jeff

    1. You can include any classes in your EJB jar file, and it is widely used. You can also include other files (e.g. properties) and access them through the class loader (as resources).
    2. If you use some libraries, you may reference them with Class-Path: element in your manifest file. It is not necessary to unpack the library and include its classes in your jar file. (About "Class-Path" -- look page about manifest in the java tutorial (in the JAR files trail)).
    3. Your JAR can contain no classes, just a deployment descriptor, if your classes are somewhere and you have referenced them with "Class-Path". ;)

  • Frmwebutil.jar Question w/ 10g (9.0.4)

    All over the Oracle documentation w/ Dev Suite and Webutil configurations it refers to frmwebutil.jar and sometimes f90webutil.jar.
    My question is, are we to use both files in various places w/ 10g (version 9.0.4) or use one or the other exclusively?
    If we are to use f90webutil.jar then I assume every reference directing us to frmwebutil.jar, we replace w/ f90webutil.jar, including signing the jar files adding to registry, .cfg files, etc...correct?
    thank you.

    Hello,
    using one of them is enough,Oracle Developer Suite 10g Release 2 (10.1.2) uses frmwebutil.jar. and the earlier release uses dev suite f90webutil.jar
    I think in your case you can use frmwebutil.jar alone.
    Regards
    Mohan

  • General JAR Questions 101

    I just completed my first ever app using the Netbeans IDE 3.6 w / sdk 1.4.2_04
    My GUI app has a main class name of : "AddRFSwitchMain" residing in a package named "AddRFSwitchPac" all in a project folder named "OW_A"
    My app requires the resources of an external multi -container "OneWireAPI" jar file.
    My app also makes use of the timer bean that came already residing in the netbeans IDE bean palette.
    All of the GUI code was constructed by using the GUI form builder tool including the timer bean56.
    Question:
    (1) To run my app outside of the IDE, I created a "jar file recipe" named "OWProject" This OWProject recipe then becomes my "compiled jar" named "ProjectOW" and runs fine when mounted "inside" the IDE . It looks to me like my "ProjectOW.jar" only makes "file location references" to the needed external "OneWireAPI.jar" I thought that my jar file would contain the "actual files" of the needed "external files" inside my jar .... is this not true? ..... as it stands, to run my app as a stand alone on another computer , with an installed "jre" , I would need to also include the "OneWireAPI".jar also to be installed on a computer running my app.
    (other questions to follow this one)

    >
    OK ... so ... "third party software" is only made
    reference to its "location" as spec'd in my app's
    manifest.
    .... and I do this in the " Class-Path: " of my app's
    manifest.Yes. (see below)
    >
    .... and I can include the "external jar" in my app's
    package for transport to other computers as one Jar.I'm not sure if that would work. (a jar within a jar). ??
    How about something like this:
    \Package Folder\
         - MyApp.jar (the main jar)
         \bin\    (folder)
              - Other Jar needed for execution of the programThen in your main jar's manifest, include "bin/OtherJar.jar".
    So the second jar will be packaged separately, away in a folder that clearly states what it contains.
    All the user would have to do is to execute the main jar. this is the only file they would have to see, from an
    execution perspective.
    Question:
    (2) As my app now stands in the netbeans IDE , my app
    "imports" these required external files from thier
    respective locations "mounted" in my IDE. ... When I
    move these external files to my "Package folder" ..I
    must now go back into my app and change any location
    reference (import statements, etc) to reflect this
    move ... correct?I don't think so: as long as your classpath (got from the manifest of the jar) includes the new locations of
    these external files.
    I think NetBeans works like this: a 'mounted' directory or file is included in the classpath.
    ie. when you click 'Compile', NetBeans passes a command to javac, specifying a few different parameters,
    and including in the classpath all the mounted files and directories (looks something like:
    "javac -classpath .;C:\Programming\Java;C:\Java\ThirdParty\OneWire; etc.", where those directories
    specified in the '-classpath' parameter are the mounted directories)
    So when you move your app out of NetBeans, all you need to do is to ensure that the required files are
    included in the classpath. If you're still working on your app in an editor, you'll need to tell the editor what to
    include in the classpath (that's how IDEs make your life easier*).
    If you are packaging your app as a jar file, you will need to specify (in relative locations) where your
    required files will be located.
    Your actual code should not need to be modified.
    Does this make sense?
    :) lutha
    * but, as you can see, they should perhaps only be used when the programmer already understands concepts like classpath! ;-) This is the view of many programmers here on these forums.

  • JAR Questions

    Hi, I have a few little questions.
    Lets say i have a jar file called powermachine.jar.
    if i want to use the classes inside of the jar(import) i need to set the CLASSPATH varible to the jar, correct?
    but what about if i distribute an application that uses classes from the jar? do i have to distribute the powermachine.jar with my application? If so how would i set up the prog so it can find the jar without changing my application code?
    thanks for any help

    Hi, I have a few little questions.
    Lets say i have a jar file called powermachine.jar.
    if i want to use the classes inside of the jar(import)
    i need to set the CLASSPATH varible to the jar,
    correct?That's right.
    >
    but what about if i distribute an application that
    uses classes from the jar? do i have to distribute the
    powermachine.jar with my application?Yes.
    If so how would
    i set up the prog so it can find the jar without
    changing my application code?
    Adding powermachine.jar to the CLASSPATH you sets for running your application.
    thanks for any helpYou're wellcome.

  • Java Development Tools - jar Question

    I have developed a application which i would like to be able to execute from a jar file (i.e. java -jar ... ).
    Anyway my gui requires some image files which are in the archive. Its just that when i try to run the application from the archive, it doesnt look within itself for the images and therefore cant find (and wont display) the images unless they are present in the same directory as the archive.
    Anyone have any ideas as to how i can get the archive to looke within itself for the images. thanks.

    Here is a snippet from one of my programs,
    I took a while to work out how to do it from a jar.
    Andrew.
    ImageIcon icon = null;
    URL iconURL = null;
    iconURL = ClassLoader.getSystemResource("comp202/fsa/vuw-logo-short.gif");
    if (iconURL != null) {
    icon = new ImageIcon(iconURL,"VUW Logo");

  • External jar question

    hi all,
    I made a Java application in Eclipse;
    in Project - Properties - Build Path - Libraries, I added an external jar to be able to connect to a mysql database.
    Now I can execute this application perfectly from Eclipse and on the same machine.
    But now I need to put this application on another machine, but when I try to execute the application it gives this error message:
    $ java WatchDog
    Cannot connect to database serverorg.gjt.mm.mysql.Driver
    Exception in thread "main" java.lang.NullPointerException
    at Query.truncate(Query.java:304)
    at WatchDog.<init>(WatchDog.java:18)
    at WatchDog.main(WatchDog.java:131)
    I also tried to point to the external jar with the -classpath option like this:
    $java -cp "/usr/local/bin/WatchDog/mysql-connector-java-5.0.4/mysql-connector-java-5.0.4-bin.jar" WatchDog
    Exception in thread "main" java.lang.NoClassDefFoundError: WatchDog
    how can I do this??
    grtz
    Message was edited by:
    dfvdfvdfvxfv

    by setting the classpath like that you removed your own classes from the classpath.
    Add the directory where those are to be found to the classpath as well.
    And of course ALWAYS use packages for your classes.

  • Ear, war and jar question.

    Hi Communtiy,
    Can I split an ear file to a war file on one computer and to a jar file on an other computer, or doesnt it makes sense.
    Thanks
    Oliver.

    we can....I am not sure in which circumstances you need this.
    There are no structural differences between the files; they are all archived using zip/jar compression. However, they are intended for different purposes.
    Jar files (files with a .jar extension) are intended to hold generic libraries of Java classes, resources, auxiliary files, etc.
    War files (files with a .war extension) are intended to contain complete Web applications. In this context, a Web application is defined as a single group of files, classes, resources, .jar files that can be packaged and accessed as one servlet context.

  • Can anyone help with a jar question?

    Okay, I'm trying to create Icon objects of particular gif files I have located in a directory /gui/common/data
    I want to be able to call these gif files in such a way that upon loading a jar file with all the necessary ingredients, it is a complete package and can be run from anywhere.
    Below is a synopsis of my code that compiles and runs fine when I run the main class from the command line ( java gui/common/src/main ) but I get a null pointer exception error when I run
    java -jar myJar.jar
    Any opinions, statements, help would be greatly appreciated.
    Thanks!
    (I'm typing from memory here, so I hope I don't make any mistakes)
    //Main class
    public class Main
    public static void main(String args[])
    Main mainSuff = new Main();
    public Main()
    Constants constants = new Constants(); ->get null pointer exception here when running jar file
    //other stuff here
    //Constants class
    public class Constants
    //I use the icon in many places so I'd like to make it "global" like this.
    public static myIcon = null;
    public Constants()
    java.net.URL url = getClass().getResource("/gui/common/data/myFile.gif");
    myIcon = new ImageIcon(url);
    in my script to create the jar file I include
    creation and class loading of the jar
    jar uvf myJar.jar gui/common/data/*.gif
    ...manifest/main file stuff

    Maybe you should try this:
    Image icon = getToolkit().getImage(url);setIconImage(icon);
    /Michael

  • Executable jar - question

    I build an executable jar or exe and I want to run this program on a system(win 2000), where there is no jdk installed. Is there any possibility to built my program in such way, so that this program would run on this system?

    Yes, try google to find the many many ways this can be done
    http://www.google.co.uk/search?q=executable+java

  • Applet in JAR Question

    Hello,
    When you publish an applet that is stored inside a JAR file, does the entire JAR file get downloaded by client browsers upon loading the page? Or do the individual class files get downloaded only when needed by the client JVM?
    Thanks,
    Andrew

    The entire jar.

  • Shorter ejb-jar.jar question.

    According to the spec Manifest files are deprecated in ejb1.1. how does
    one make reference to another EJB without it? IE. is the <ejb-ref> tags in
    the deployment descriptor enough or do these classes need to be included in
    the jar file ?
    Thanks for any help
    Steve Wanhella [email protected]

    Hi maity,
    J2EE 1.4 implementations are required to support what is known as an Installed Library.
    This is a .jar file that is added to the application server installation such that individual
    applications have visibility to the classes without packaging those classes within the .ear files
    themselves. Consult your vendor's documentation for specifics on how to do it.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • YET another double-clicking a jar question!

    Hi all.
    Sorry about this but I've been searching this forum for the last couple of hours and I still can't figure out why I can't double-click my jar file.
    I've 'jarred' my application into a file named <i>parserTTe.jar</i>.
    This jar includes a package named <i>parser</i>, wich includes the main class <i>Parser</i>, and several other subpackages.
    In the manifest file (created by ant 1.5), there is an entry as follows:
    Main-Class: parser.Parser
    followed by a couple of blank lines.
    The main method of <i>Parser</i> class demands as an argument the path to the file to parse.
    Now, if I run the command line <b>java -jar parserTTe.jar <i>pathtosomefile</i></b>, everything works smoothly.
    As the parser does its job, I can watch its verbose flowing in the command line window.
    If I double-click the jar file, though, <b>nothing happens</b> and I would expect that a <i>java.lang.ArrayIndexOutOfBounsException</i> would be thrown, as it does when I simply run <b>java parser.Parser</b>.
    If instead of double-clicking the jar, I run the command line <b>parserTTe.jar <i>pathtosomefile</i></b> or just <b>parserTTe.jar</b>, still nothing happens, the command line just refreshes.
    My WNT is set to recognize jar files as Executable Jar Files and the open action is set as follows:
    C:\...\javaw.exe" -jar "%1".
    I've tried changing this to <i>java.exe</i> instead of <i>javaw.exe</i> but then I get a <i>java.lang.ArrayIndexOutOfBounsException</i>, either if I specify the path to the file to parse or not.
    Currently I'm bypassing this problem using a <i>parserTTe.bat</i> file, wich works, of course, but I'm annoyed for not understanding what's wrong: why can't I run the jar file directly?
    Thanks for your help!

    And where do you expect that argument to come from if
    you double-click to run the class? That's why you are
    getting the array index exception, because your class
    is being called with no parameters. You need to
    redesign your class so that it prompts the user for
    the file name; and since it's being run via javaw.exe,
    it will have to use a GUI to prompt. A JFileChooser
    would be a good choice.Please look closer to my description: I said I'd be expecting that exception to be thrown because of what you say but the problem is that it doesn't.
    In fact, nothing happens when I double click it, or when I run it directly from the command line, passing along the needed argument or not.
    Let us forget about the double-clicking that I won't use anyway.
    What puzzles me is that I should be able to run that jar as if it was a bat file. I do it all the time with other apps I've built, although none of them requires a starting argument...
    Like I explained, I thought it could be something related with the javaw.exe so I set WNT to open jar files with java.exe and not javaw.exe.
    The double-clicking resulted in a DOS Prompt window that opened and closed before I could see what happened. So I thought: it's ok. It threw an exception because no argument was passed.
    Then I tried to run the jar from the command line passing the argument but the exception was thrown again, though, wich I didn't understand why.
    Basically, that's it.
    Thanks anyway for your time.

  • Making a jar  - question

    I have my java file, along a properties that file that it needs and of course the class file. Can I make these into a jar file that I can then run from a shell script?

    or to be more specific this link

Maybe you are looking for

  • DataSource Configuration

    When I am trying to start ACC I am getting following errors: 13:43:48,857 ERROR [Registry] Error registering jboss.web:type=RequestProcessor,worker=http-0.0.0.0-8080,name=HttpRequest2 java.lang.SecurityException: MBeanTrustPermission(register) not im

  • Out of memory errors w/ MappedByteBuffers

    Hello, I'm having problems using a MappedByteBuffer on a file that is just over 1 gig. I see this error: file size: 1104924640 java.io.IOException: Map failed         at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:761)         at com.ibm.esup

  • Validate data - business rules.

    Hi, We're using CDM Ruleframe to implement our business rules. As there was a need to bulk load a bunch of data, I disabled the business rules temporarily using the procedure disable_all_br. Is there a way to find out (afterwards) which of the record

  • Restore Mail?

    How do I restore mail after a system re-install? I tried moving the mail folder from Previous System but it didn't work. (Still made me setup new mail account). TIA! Jennifer

  • Using safari as web browser in a classic application

    I have version 5 of adobe go live and I use it in classic mode in osx.4.8. In order to create my web site I need to specify safari as the web browser, can this be done?