Using files in a jar

I'm having an issue, it's really kind of strange to me...
I am using the Sun One Studio 4 CE to devel. applications
I have created two apps in sep directories but under the same parent dir.
parent_dir
|
|- Child_1
| |- File1.class
| |- data_dir
| | |- resource.bmp
|
|- Child_2
| |- File2.class
| |- data_dir
| | |- resource.bmp
I have created Jar files for these packages which is fine creating and compiling the jar files...
I attempt to run the jar files, and the first jar, in Child_1, works fine using the resource.bmp but the second doesn't
the jar files each have all the files needed to correctly run the apps because i have tested them and the code is correct. I have the mf file in the second jar as well i have already looked at that...I cannot figure out what the problem might be...any help on this would be wonderful! :)
thanks for the help
- nc

nope
it's set properly because i can run the file properly and everything works outside of the jar
but once inside the jar it screws up even while the path is correct
this is more specific
i have two files named Mud.bmp and World.txt in a subdir of World_Structure where the classes and source files are
these files need to be read into my program, i have this so that it works...not a problem
outside of the jar this works and the files are found.
public URL getResource(String filename)
// Try to load resource from jar
URL url = getClass().getResource(filename);
return url;
this returns a URL to the files i want. It works in that first jar properly loading a .png file
but the txt and bmp wont work. I don't suspect it has anything to do with extensions but i'm trying to give as much information as possible.
The jar has everything in the directory including subdirs except *.java, *.frm, and *.jar
so the files are in the jar itself when it's created
hope this gives a better understanding of the problem
thanks :)
- nc

Similar Messages

  • File objects in jar file

    Hi!
    Is their some kind of way one can use File objects in a jar file plz? I have a project which is complete and working well on the IDE but now that I have jarred it, i've come to realize that apparently file objects do not relate well with .jar files. The problem is that the program makes a lot of file manipulations and changing everything to getResource, InputStream etc would be very lengthy. So there's absolutely no way in which one can use File objects in jar files?
    Any help would be very much appreciated!
    Thanks and regards,
    Krt_Malta

    You can use the java.net.JarURLConnection class (use file:/// when creating the URL) to get a URL to a jar entry, create a URI from the URL, and then create a File object on the URI.
    Or use java.util.jar.JarFile methods and its associated classes to get jar entry contents.
    While you can use these approaches to create File objects from a jar, they are not any easier than what's already been mentioned.
    And all you can do is read or delete a jar - jar entries can't be rewritten.

  • Problem with JSP using bean packaged in jar file

    Hi,
              I am trying to use a java bean in a jsp file. The java bean is packaged
              into a jar file. I am getting class not found compilation error. If the
              bean remains to be a seperated class file, everything work well.
              Does anyone know how I can use bean in a jar file within jsp , i.e. to
              allow the bean to be found during compilation ?
              Thanks,
              Terence.
              [email protected]
              

    Jacek,
              Thanks for replying.
              My JSP's are just files in my document root . However, I found a solution to
              my
              problem. That is to have the jar file defined in my weblogic.class.path. I may
              have missed some files in my original jar file which causes my problem.
              Mayby I should package everything into a web application for deployment. That
              will be my next step.
              Thanks anyway.
              Terence.
              Jacek Laskowski wrote:
              > Terence Lai wrote:
              > >
              > > Hi,
              > >
              > > I am trying to use a java bean in a jsp file. The java bean is packaged
              > > into a jar file. I am getting class not found compilation error. If the
              > > bean remains to be a seperated class file, everything work well.
              >
              > How do you use the JSP file ? Is it a part of web application ? If so,
              > the bean jar package should be located in WEB-INF/lib directory. It's
              > also recommended to put the bean class into a package, so it's not in
              > 'unnamed' package, and <jsp:useBean> can find it.
              >
              > >
              > > Does anyone know how I can use bean in a jar file within jsp , i.e. to
              > > allow the bean to be found during compilation ?
              >
              > see above.
              >
              > > Terence.
              >
              > Jacek Laskowski
              > HP Consulting
              

  • How to use Stylesheets packaged in JAR file

    Hi,
    I would like to package XSL files in a JAR. The stylesheet may import other XSL files. For example:
    <xsl:import href="demos.xsl">
    <xsl:import href="table.xsl">
    where the original stylesheet and the imported stylesheets (demos.xsl and table.xsl) are all located in this package: com.company.xsl
    Is there a way for the transformers to retrieve the files from the JAR?
    Possibly another complication is that this JAR file is loaded at runtime.
    Any suggestions would be of great help. Thanks!

    Thanks that worked.
    However, is it possible to use a relative path? Right now it only works if the absolute path is used:
    <xsl:import href="jar:file:///c:/applications/bin/myjar.jar!/com/company/xsl/table.xsl" />
    It would be nice if this worked instead:
    <xsl:import href="jar:file:///./bin/myjar.jar!/com/company/xsl/table.xsl" />

  • Can Netbeans put a jar file In a jar file?

    I just went through the process of getting Eclipse to create a jar file that would execute from a command prompt using a plugin called fatjar :
    http://fjep.sourceforge.net/
    Details from other thread :http://forum.java.sun.com/thread.jspa?threadID=5219638&tstart=0
    I really would like to use netbeans but i now have the exact same problem trying to make a jar file in netbeans 5.5.1
    I am using a package from icaste.com It has a
    .dll file to put in the windows directory
    JCommSerial_3_0.jar file that contains all the classes
    I can compile and run a file in the IDE and it works fine
    The Jar file does not contain the classes so i get errors when running from command line.
    Here is the layout of my screen and result of run command in IDE
    http://www.acousticlights.com/netbeans.png
    What do I need to try?

    georgemc wrote:
    Why is everyone so obsessed with doing this? The gains are minimal and the problems numerousBecause we are new and don't understand how the java VM actually runs code and the error messages sent by the java machine are cryptic.
    My first attempt at using an external jar in a java program lead me to believe that all of the code for a java program would be in a jar file including external jar files, after all the JDK standard library has tons of jars in it so I assumed the external jar file would be linked (as most other programming compiler/linkers I have worked with in my top down programming life).
    I find out the answer is so simple that the external jar file could not be found by the VM running my jar file. Like I said, if the VM would have just gave me an error that it could not find a file on a specific directory i never would have perused the idea of jar in a jar (fatjar plugin for Eclipse for example)
    Really this is like getting into a race car and not knowing at what RPM to shift gears, sure you can press the pedal and make it go but if you don't understand how it works under the hood you are going to blow the engine if you keep it in first gear.
    I have read many posts on these errors, the reason is the error message is just not very descriptive of the original problem. If I try and open a database called xyz.dbf that has one field defined as lastname, in C for example, I would not give the error message "Lastname could not be found) when indeed the lastname could not be found but the reason it could not be found was because the database xyz.dbf could not be found. Further , adding to the error message that the system is looking for xyz.dbf on drive X- subdirectory -mydatabases would complete the error message and allow the user to fix the error. Just what is a non java programmer that is using my java program suppose to do with an Ecception Error in (main) bla bla bla... I know now I need to check for library files myself within my own java programs and give a better error message to the user before the java VM sends out it's cryptic message.
    Edited by: metron9 on Sep 25, 2007 11:00 AM

  • How to add dll file in a Jar to create executable file

    Hi All!
    I have one Java file which use one Jar file & three dll file.
    I create jar file as described in java tutorial
    http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html
    1) I created Manifiest.txt by writting :
    Class-Path: C:\Flasher\jflashtrial\JFlash.jar
    Main-Class: Flaher2
    2) I create jar file by:
    jar cfm MyJar.jar Manifest.txt *.class
    It create MyJar.jar successfully.
    After that I used Jar2Exe Wizard to create Myjar.exe
    It also create MyJar.exe file, but when I tried to open It , It did open & also didn't give any error message too.
    Before this I created one exe file by the same way except; that file does not using any dll or jar file so for that I create my jar file by simply without using Manifest.txt
    I wrote:
    jar cf MyJar.jar *.class
    After that I creat it's exe bu using Jar2Exe, It create its exe file & it's work well.
    So for my next try with one jar file & three dll file, what is wrong ?
    I saved my exe jar file & dll filea file in a same folder. But still have a problem .
    What I did wrong/skip in creating Jar file.
    Your any help regarding this topic would be appreciated
    Kirti

    Hello,
    Getting all of this to work right is a bit of a challenge. I haven't used jar2exe at all, but we have a number of native libraries that we support that have to use dll's. I would recommend adding a static initializer like
    public class flup {
    static {
    try {
    System.loadLibrary("flup"); // will look for flup.dll in the %PATH%
    } catch (Exception e) {
    e.printStackTrace();
    This should give you a little more information about what is failing. Chances are the dll's are not in the PATH. You may be able to get around this by using regsvr32 to register the Dll's but I have had mixed results with that solution.
    You also may be able to write a simple c++ program that uses the dll's (or maybe you already know of one) and use the "depends.exe" program from Microsoft's Platform SDK to examine the full dll dependency tree if you continue to have problems.
    Best of Luck,
    Andrew

  • How do I read a text file in a Jar Executable?

    Hello All,
    I have a need to package a text file into a Jar Exectable file and then have my java code read that text file in using a BufferedReader. Can anyone out there tell me how to do this? My first question is how do I reference this file by the path name? O, I'm also using Windows.
    Thanks for your help.
    Karl

    I have the same problem with kportner . I did by joop_eggen but I got the error at:
    BufferedReader in = new InputStreamReader(is);Can't conver from BufferedReader to InputStreamReader
    When I up my applet to server and get it from client. My applet couldn't read the text file.
    Any one help me!
    Thanks.

  • How can  I access my java class file in a .jar file ...PLz Help anyone!!

    Hi Folks,
    I am new in Java programming, have a .jar file that contains .java files that I want no access and use from another .java file. These files in the .jar file basically form a library thus have no main-method. However I can not declare an instance of the library (in the .jar file) and use it within my program.
    Plz help ...I have tried all I know in vain.
    Thanks.

    temba wrote:
    Hi Folks,
    I am new in Java programming, have a .jar file that contains .java files that I want no access and use from another .java file. These files in the .jar file basically form a library thus have no main-method. However I can not declare an instance of the library (in the .jar file) and use it within my program. You are making little sense. You can't instantiate .java files.
    Plz help ...I have tried all I know in vain.
    Thanks.Could you post WHAT you have tried and also post what error messages you received?

  • How to run class files in a jar independently.

    Hello all
    I have a java file which use an API.jar file which is an API file of some other application of mine.This file form a sought of client for that application.Now i want to run this file from command line which is giving NoClassDefFoundError exception.This exception is because of the dependency over API.jar.I dont want to pack this single file into a jar and then run that jar since it only makes a simple task complicated and makes a simple class look like a big application.Can anybody tell me the solution to it?
    Regards,
    Mansi

    MansiSachar wrote:
    I am working on WindowsXP and the command u just sent is again giving the same exception.The exception is :
    Exception in thread "main" java.lang.NoClassDefFoundError: ûcp
    Caused by: java.lang.ClassNotFoundException: ûcp
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    I think the problem can also be the placement of the dependant jars.do i need to keep them in "bin" folder?I am assuming that in the error message, it says "-cp" not "ûcp" Can you confirm that you entered the command as posted? Because it looks like java.exe sees the -cp as the class to execute instead of the classpath option.
    Try using -classpath instead of -cp. What version of java are you using? (java -version should give you the version).
    If the jars are in the current directory, the placement of the jar files is correct.

  • Listing files in a jar, one screen at a time

    I need to list all the files in a .jar file from the DOS command line (using jar tf etc.). There are so many files that half of the list scrolls above the top of the window before the end of the list is displayed, so I can't see half the list. How do I tell it to pause the list when the screen is full, then continue scrolling only when I hit come key? I tried using \p (which is used in DOS) but that doesn't work.

    Redirect the output to a file, and then use Notepad to display the contents of that file.
    jar ... >somefile.txt

  • Error in using file adapter valves

    Hi,
    I'm working on Oracle SOA Suite 11g (11.1.1.4). I'm doing an exercise on using adapter valves for encryption. I need to write an encrypted file using File adapter. I created pipeline.xml and also specified property in jca file. And added bpm-infra.jar file to classpath.
    Also, I've compiled SimpleEncryptValve.java and created a jar file and placed it in lib directory of domain.
    Pipeline.xml is as below :
    <?xml version="1.0"?>
    <pipeline xmlns="https://www.oracle.com/adapter/pipeline">
    <valves>
    <valve>valves.SimpleEncryptValve</valve>
    </valves>
    </pipeline>
    writeFile_file.jca contents are as below :
    <adapter-config name="writeFile" adapter="File Adapter" wsdlLocation="writeFile.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
    <connection-factory location="eis/FileAdapter"/>
    <endpoint-interaction portType="Write_ptt" operation="Write">
    <interaction-spec className="oracle.tip.adapter.file.outbound.FileInteractionSpec">
    <property name="PhysicalDirectory" value="D:\PoC\FileAdapters"/>
    <property name="Append" value="false"/>
    <property name="FileNamingConvention" value="new_%SEQ%.txt"/>
    <property name="NumberMessages" value="1"/>
    <property name="PipelineFile" value="pipeline.xml"/>
    </interaction-spec>
    </endpoint-interaction>
    </adapter-config>
    Got below error while testing. What could be wrong in valve configuration ?
    <Jun 6, 2011 7:29:25 PM IST> <Error> <oracle.soa.adapter> <BEA-000000> <File
    pter Project2:writeFile [ Write_ptt::Write(body) ]
    oracle.tip.pc.services.pipeline.PipelineException: Invalid configurations for valves
    at oracle.tip.pc.services.pipeline.PipelineImpl.validate(PipelineImpl
    va:237)
    at oracle.tip.pc.services.pipeline.PipelineFactory.instantiateModel(P
    lineFactory.java:198)
    at oracle.tip.pc.services.pipeline.PipelineTemplate.newPipeline(Pipel
    Template.java:39)
    at oracle.tip.adapter.file.outbound.FileSender.getPipeline(FileSender
    va:378)
    at oracle.tip.adapter.file.outbound.FileSender.sendNonBatchedSerializ
    late(FileSender.java:254)
    at oracle.tip.adapter.file.outbound.FileInteraction.executeFileWrite(
    eInteraction.java:623)
    at oracle.tip.adapter.file.outbound.FileInteraction.execute(FileInter
    ion.java:426)
    at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteracti
    nvoker.executeJcaInteraction(JCAInteractionInvoker.java:311)
    at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteracti
    nvoker.invokeJcaReference(JCAInteractionInvoker.java:548)
    at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteracti
    nvoker.invokeAsyncJcaReference(JCAInteractionInvoker.java:508)
    at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAEndpointI
    raction.performAsynchronousInteraction(JCAEndpointInteraction.java:491)
    at oracle.integration.platform.blocks.adapter.AdapterReference.post(A
    terReference.java:247)
    at oracle.integration.platform.blocks.mesh.AsynchronousMessageHandler
    Post(AsynchronousMessageHandler.java:142)
    at oracle.integration.platform.blocks.mesh.MessageRouter.post(Message
    ter.java:194)
    at oracle.integration.platform.blocks.mesh.MeshImpl.post(MeshImpl.jav
    15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorIm
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingRefle
    on(AopUtils.java:307)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invok
    inpoint(ReflectiveMethodInvocation.java:182)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proce
    ReflectiveMethodInvocation.java:149)
    at oracle.integration.platform.metrics.PhaseEventAspect.invoke(PhaseE
    tAspect.java:71)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proce
    ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDyn
    cAopProxy.java:204)
    at $Proxy299.post(Unknown Source)
    at oracle.tip.mediator.serviceEngine.MediatorServiceEngine.post2Mesh(
    iatorServiceEngine.java:1120)
    at oracle.tip.mediator.service.BaseActionHandler.requestProcess(BaseA
    onHandler.java:200)
    at oracle.tip.mediator.service.BaseActionHandler.requestProcess(BaseA
    onHandler.java:94)
    at oracle.tip.mediator.service.BaseActionHandler.requestProcess(BaseA
    onHandler.java:74)
    at oracle.tip.mediator.service.OneWayActionHandler.process(OneWayActi
    andler.java:47)
    at oracle.tip.mediator.service.ActionProcessor.onMessage(ActionProces
    .java:64)
    at oracle.tip.mediator.dispatch.MessageDispatcher.executeCase(Message
    patcher.java:137)
    at oracle.tip.mediator.dispatch.InitialMessageDispatcher.processCase(
    tialMessageDispatcher.java:503)
    at oracle.tip.mediator.dispatch.InitialMessageDispatcher.processCases
    itialMessageDispatcher.java:401)
    at oracle.tip.mediator.dispatch.InitialMessageDispatcher.processNorma
    ses(InitialMessageDispatcher.java:284)
    at oracle.tip.mediator.dispatch.InitialMessageDispatcher.processCases
    itialMessageDispatcher.java:251)
    at oracle.tip.mediator.dispatch.InitialMessageDispatcher.dispatch(Ini
    lMessageDispatcher.java:143)
    at oracle.tip.mediator.serviceEngine.MediatorServiceEngine.process(Me
    torServiceEngine.java:848)
    at oracle.tip.mediator.serviceEngine.MediatorServiceEngine.post(Media
    ServiceEngine.java:624)
    at oracle.integration.platform.blocks.mesh.AsynchronousMessageHandler
    Post(AsynchronousMessageHandler.java:142)
    at oracle.integration.platform.blocks.mesh.MessageRouter.post(Message
    ter.java:194)
    at oracle.integration.platform.blocks.mesh.MeshImpl.post(MeshImpl.jav
    15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorIm
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingRefle
    on(AopUtils.java:307)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invok
    inpoint(ReflectiveMethodInvocation.java:182)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proce
    ReflectiveMethodInvocation.java:149)
    at oracle.integration.platform.metrics.PhaseEventAspect.invoke(PhaseE
    tAspect.java:59)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proce
    ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDyn
    cAopProxy.java:204)
    at $Proxy299.post(Unknown Source)
    at oracle.integration.platform.blocks.soap.WebServiceEntryBindingComp
    nt.doMessageProcessing(WebServiceEntryBindingComponent.java:1271)
    at oracle.integration.platform.blocks.soap.WebServiceEntryBindingComp
    nt.processIncomingMessage(WebServiceEntryBindingComponent.java:859)
    at oracle.integration.platform.blocks.soap.FabricProvider.processMess
    (FabricProvider.java:113)
    at oracle.j2ee.ws.server.provider.ProviderProcessor.doEndpointProcess
    (ProviderProcessor.java:1187)
    at oracle.j2ee.ws.server.WebServiceProcessor.invokeEndpointImplementa
    n(WebServiceProcessor.java:1081)
    at oracle.j2ee.ws.server.provider.ProviderProcessor.doRequestProcessi
    ProviderProcessor.java:581)
    at oracle.j2ee.ws.server.WebServiceProcessor.processRequest(WebServic
    ocessor.java:232)
    at oracle.j2ee.ws.server.WebServiceProcessor.doService(WebServiceProc
    or.java:192)
    at oracle.j2ee.ws.server.WebServiceServlet.doPost(WebServiceServlet.j
    :459)
    at oracle.integration.platform.blocks.soap.FabricProviderServlet.doPo
    FabricProviderServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.
    (StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSec
    tyHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.
    a:300)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl
    va:56)
    at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:1
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java
    3)
    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatfor
    il.java:413)
    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.
    a:94)
    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.jav
    61)
    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl
    va:56)
    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java
    6)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl
    va:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAc
    n.wrapRun(WebAppServletContext.java:3715)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAc
    n.run(WebAppServletContext.java:3681)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authentic
    dSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.ja
    120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebA
    ervletContext.java:2277)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServl
    ontext.java:2183)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImp
    ava:1454)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
    >

    Hi Surfraz,
    Did you go through this link?
    http://docs.oracle.com/cd/E21764_01/integration.1111/e10231/adptr_file.htm#BABCFDGC
    Regards,
    Neeraj Sehgal

  • Unable to read a .gif file from a jar

    I have made an application which requires some .gif images.
    I packed all the classes and .gif's in a jar file.
    I have used no package statement in files, all are in one folder.
    While retrieving the .gif file from the jar I have used..
    Image img1 = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("Lock.gif"));
    ImageIcon i1=new ImageIcon(img1,"No Users");
    but this does not works and throws nullpointer exception.
    I have also tried getClass().getResource() etc.
    But none of the methods are working..
    Plz. help.
    Nimesh

    Is the class that is loading the image contained in a package? If the resource name does not start with a forward slash, it is interpreted as relative to the package of your class(when doing getClass().getResource())

  • Problem using File upload in portlets

    hello there
    I'm trying to use file upload component in one of my portlets. I searched a lot about a working component to be used in portlets since the standard one that comes with JSC doesn't work in portlets. I managed to get commons file upload and tomahawk to run in my portlet, but when I choose a file and try to get selected file's details it throughs a NullPointerException reporting that the file object is null.
    so please can anyone guide me to a working portlet example, I tried to find one but I couldn't. if that's hard to find, what should I do ?
    thank you in advance

    I added file upload component in JSF from portlets in Sun Java Portal server.
    Take a look...
    portlet.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
    version="1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
    <portlet>
    <description>SFTB Anonymous Mail Portlet</description>
    <portlet-name>SFTBAnonymousMailPortlet</portlet-name>
    <display-name>SFTBAnonymousMailPortlet</display-name>
    <portlet-class>org.apache.portals.bridges.portletfilter.FilterPortlet</portlet-class>
    <init-param>
    <name>portlet-class</name>
    <value>com.sun.faces.portlet.FacesPortlet</value>
    </init-param>
    <!-- Filter for MyFaces Tomahawk extension. -->
    <init-param>
    <name>portlet-filters</name>
    <value>jp.sf.pal.tomahawk.filter.ExtensionsPortletFilter</value>
    </init-param>
    <init-param>
    <description>Portlet init page</description>
    <name>com.sun.faces.portlet.INIT_VIEW</name>
    <value>/jsp/index.jsp</value>
    </init-param>
    <supports>
    <mime-type>text/html</mime-type>
    <portlet-mode>VIEW</portlet-mode>
    <portlet-mode>EDIT</portlet-mode>
    <portlet-mode>HELP</portlet-mode>
    </supports>
    <portlet-info>
    <title>&#1054;&#1090;&#1087;&#1088;&#1072;&#1074;&#1082;&#1072; &#1087;&#1088;&#1077;&#1076;&#1083;&#1086;&#1078;&#1077;&#1085;&#1080;&#1081;</title>
    <short-title>&#1054;&#1090;&#1087;&#1088;&#1072;&#1074;&#1082;&#1072; &#1087;&#1088;&#1077;&#1076;&#1083;&#1086;&#1078;&#1077;&#1085;&#1080;&#1081;</short-title>
    </portlet-info>
    </portlet>
    </portlet-app>
    web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <display-name>SFTBAnonymousMailComment</display-name>
    <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>
    <!--
    Extensions filter from Apache MyFaces Tomahawk used for uploads files.
    -->
    <filter>
    <filter-name>ExtensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    <init-param>
    <param-name>uploadMaxFileSize</param-name>
    <param-value>10m</param-value>
    <description>Set the size limit for uploaded files.
    Format: 10 - 10 bytes
    10k - 10 KB
    10m - 10 MB
    1g - 1 GB
    </description>
    </init-param>
    <init-param>
    <param-name>uploadThresholdSize</param-name>
    <param-value>100k</param-value>
    <description>Set the threshold size - files
    below this limit are stored in memory, files above
    this limit are stored on disk.
    Format: 10 - 10 bytes
    10k - 10 KB
    10m - 10 MB
    1g - 1 GB
    </description>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>ExtensionsFilter</filter-name>
    <servlet-name>FacesServlet</servlet-name>
    </filter-mapping>
    <servlet>
    <servlet-name>FacesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>FacesServlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    </web-app>
    Files in WEB-INF/lib
    commons-beanutils-1.7.0.jar
    commons-collections-3.2.jar
    commons-digester-1.8.jar
    commons-fileupload-1.2.1.jar
    commons-io-1.2.jar
    commons-logging-1.1.1.jar
    faces-response-filter-0.2.jar
    jsf-api-1.1_02.jar
    jsf-impl-1.1_02.jar
    jsf-portlet-1.1.5.jar
    jstl-1.1.0-D13.jar
    log4j-1.2.9.jar
    portals-bridges-portletfilter-1.0.jar
    standard-1.1.0-D13.jar
    tomahawk-1.1.6.jar
    tomahawk-bridge-0.9.1.jar
    Files tomahawk-bridge-0.9.1.jar, faces-response-filter-0.2.jar may be found there http://sourceforge.jp/projects/pal/
    In JSF beans I'm using org.apache.myfaces.custom.fileupload.UploadedFile
    Hope this helps.
    Bests,
    Alex Magdenko

  • Reading an xml file from a jar file

    Short question:
    Is it possible to read an xml file from a jar file when the dtd is
    placed inside the jar file? I am using jdom (SAXBuilder) and the default
    sax parser which comes with it.
    Long Question:
    I am trying to create an enterprise archive file on Weblogic 6.1. We
    have a framework that is similar to the struts framework which uses it's
    own configuration files
    I could place the dtd files outside the jar ear file and specify the
    absolute path in an environment variable in web.xml which is
    configurable through the admin console.
    But I want to avoid this step and specify a relative path within the jar
    file.
    I have tried to use a class which implements the entityresolver as well
    as try to extend the saxparser and set the entity resolver within this
    class explicitly, but I always seem to sun into problems like:
    The setEntityresolver method does not get called or there is a
    classloader problem. i.e. JDOM complains that it cannot load My custom
    parser which is part of the application
    Vijay

    Please contact the main BEA Support team [email protected]
    They will need to check with product support to determine
    the interoperatablity of Weblogic Server with these other
    products.

  • How do I write to a file in a jar?  I seached the forums but couldn't find.

    I need to write to a .txt file in a jar. Can that be done?

    A JAR file is just a ZIP file that you can fiddle with using WinZip, as you probably know. Offhand, I don't know of any API classes for writing these files. But it's hard to imagine why a program (other than a Java development tool) would need to write to a JAR file, as opposed to writing the text file "normally" somewhere (e.g., to your program's installation directory).

Maybe you are looking for

  • Custom de disponibilizacao do XML via WebService

    Srs. Preciso da ajuda de vocês em uma solução custom que estou criando via WebServices de disponibilizacao do arquivo XML gerado pelo SEFAZ. O problema que estou tendo é que, informando um ID de uma NFe, não estou conseguindo ler todos os dados do XM

  • I am trying to install my Creative Cloud

    I am trying to install my Creative Cloud however it doesn't seem to work. Says I need to buy them. Could the trial version that my boyfriend installed on his account be effecting this?

  • IMovie is a HOG!!

    what other options are there for iMovie that are compatible with Mac OS and, hopefully, free?? i briefly looked elsewhere on this forum about this topic, maybe poor search choices, but iMovie is a memory pig. here's the story- bought a GoPro for moun

  • Efficientl​y building an array of increasing values for a graph

    I need to build an array of values increasing by 3E-8.  Initializing an array and changing each value in a while loop works fine, but it is terribly slow.  Is there a better (faster) way of building an array of increasing values like this?

  • Material Moving Price and Standard Price

    Hello All, what could be the reason for having both the Moving Av.Price and Standard price in Material Master of FERT? Can anyone explain me the business case Thanks Arshad Edited by: arshad ahmed on Apr 21, 2009 8:35 AM