How can I assign image file name from Main() class

I am trying to create library class which will be accessed and used by different applications (with different image files to be assigned). So, what image file to call should be determined by and in the Main class.
Here is the Main class
import org.me.lib.MyJNIWindowClass;
public class Main {
public Main() {
public static void main(String[] args) {
MyJNIWindowClass mw = new MyJNIWindowClass();
mw.s = "clock.gif";
And here is the library class
package org.me.lib;
public class MyJNIWindowClass {
public String s;
ImageIcon image = new ImageIcon("C:/Documents and Settings/Administrator/Desktop/" + s);
public MyJNIWindowClass() {
JLabel jl = new JLabel(image);
JFrame jf = new JFrame();
jf.add(jl);
jf.setVisible(true);
jf.pack();
I do understand that when I am making reference from main() method to MyJNIWindowClass() s first initialized to null and that is why clock could not be seen but how can I assign image file name from Main() class for library class without creating reference to Main() from MyJNIWindowClass()? As I said, I want this library class being accessed from different applications (means different Main() classes).
Thank you.

Your problem is one of timing. Consider this simple example.
public class Example {
    public String s;
    private String message = "Hello, " + s;
    public String toString() {
        return message;
    public static void main(String[] args) {
        Example ex = new Example();
        ex.s = "world";
        System.out.println(ex.toString());
}When this code is executed, the following happens in order:
1. new Example() is executed, causing an object to constructed. In particular:
2. field s is given value null (since no value is explicitly assigned.
3. field message is given value "Hello, null"
4. Back in method main, field s is now given value "world", but that
doesn't change message.
5. Finally, "Hello, null" is output.
The following fixes the above example:
public class Example {
    private String message;
    public Example(String name) {
        message = "Hello, " + name;
    public String toString() {
        return message;
    public static void main(String[] args) {
        Example ex = new Example("world");
        System.out.println(ex.toString());
}

Similar Messages

  • How do I call image file names from MySQL & display the image?

    Hello everyone,
    I have image file names (not the full URL) stored in a MySQL database. The MySQL database is part of MAMP 1.7 and I am using Dreamweaver CS3 on a Mac Book Pro.
    I would like to create a catalog page using thumbnails, and PayPal buttons displayed within a table, in rows. With the image centered and the PayPal button directly underneath the image.
    How do I use PHP to call the thumbnail images as an image not the file name, to be displayed in the table?
    Thanks in advance.

    slam38 wrote:
    How do I use PHP to call the thumbnail images as an image not the file name, to be displayed in the table?
    Open the Insert Image dialog box in the normal way, and navigate to the folder that contains the images. Then copy to your clipboard the value in the URL field, and click the Data Sources button. The following screenshot was taken in the Windows version, but the only difference is that Data Sources is a radio button at the top of the dialog box in Windows. It's a button at the bottom in the Mac:
    After selecting Data Sources, select the image field from the approriate recordset. Then put your cursor in the URL field and paste in the path that you copied to your clipboard earlier.

  • How-can-i-remove-my-skype-name-from-the-sign-in-sc...

    Guys this is absolute rubbish feature of the login application where people's login names get recorded in the dropdown menu. Is there any more permanent way of getting rid of this annoying privacy intrusive "feature"? I would like to have a profile with a username that is not going to appear at airports and my grandma's laptop after I log out of skype and no I do not want to go digging for app files to remove my entire history on each and every machine I use as suggested by your help files. Could you please advise if I'm missing something here?
    https://support.skype.com/en-gb/faq/FA11070/how-can-i-remove-my-skype-name-from-the-sign-in-screen-i...

    Unfortunately, the option to remove that feature is not available.  
    IF YOU FOUND OUR POST USEFUL THEN PLEASE GIVE "KUDOS". IF IT HELPED TO FIX YOUR ISSUE PLEASE MARK IT AS A "SOLUTION" TO HELP OTHERS. THANKS!
    ALTERNATIVE SKYPE DOWNLOAD LINKS | HOW TO RECORD SKYPE VIDEO CALLS | HOW TO HANDLE SUSPICIOS CALLS AND MESSAGES
    SEE MORE TIPS, TRICKS, TUTORIALS AND UPDATES in
    | skypefordummies.blogspot.com | 

  • How to get the long file name from an 8.3 name in Windows.

    Because of a legacy string limitation, I have a list of files in 8.3 format. The actual files are saved with long names. How can I get the long name from the short name?
    In JavaScript, I would get a file system object and get the file object from there with the short name. Then it's no problem to get the full name. But I don't see anything in Java that matches that. ???
    Ideas?
    Frank Perry, MSEE

    Here is what I did.
    String displayName = "somefi~1.txt";
    File fO = new File("c:\\"); // I have a more involved path but that's not important here.
    String stPath = fO.getPath() + displayName;
    File fD = new File(stPath); // get the file using the short name.
    File fDc = new File(fD.getCanonicalPath()); // get another file using the cononical name
    String FulldisplayName = fDc.getName(); // get the long name from there.
    It's roundabout but it works. Since getName() on the file read with the short name only returns the name used to get the file, I open it twice. The alternative is to parse the cononical name for the file name but that's clumbsy too.
    Frank

  • How can I transfer two user names from an iMac to a new macbook?

    How can I transfer two user names from an iMac to a new macbook?
    got a new laptop and need to transfer two usernames to it, complete with all documents help?

    Assuming you haven't already set up a user, the easiest way is to use the Setup Assistant during first boot of the new Mac, with the two Macs connected by firewire.
    You'll be prompted to migrate from a choice of sources - choose "from another Mac", select the catagories of data you want to transfer and follow the instructions.
    More info here, in Pondini's FAQ; http://pondini.org/OSX/SetupAsst.html

  • How can I add image files to a executable jar file ?

    Could you tell me how can I add image files to executable jar file ?
    package structure:
    ../com/Main.class
    ../images/..

    Please don't cross post, and read this
    http://forum.java.sun.com/thread.jsp?forum=31&thread=271751
    I've answered the question in the New To Java thread.

  • How can I edit the file name of the home page?

    How can I edit the file name of the home page?
    Gr Ammani

    I have a similar issue with regards to the filename...
    When I navigate to my website, it doesnt work unless I actually type the filename at the end of it. Example: type in "www.whitelion.com" (this is my real domain name) and it doesnt work. When I type in "www.whitelion.com/index.html" then it works.
    This is obviously inconvenient because my clients will never know to add the filename to the end of the site.
    Is there any setting or way to get the page to appear by just typing the original domain name without adding the extension?
    Thanks,
    Emelia

  • How to get list of file names from a directory?

    How to get list of file names from a directory?
    Please help

    In addition, this:
    String filename = files;Should be this:
    String filename = files;
    That's just because he didn't use the "code" tags, so [ i ] made everything following it become italicized.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • When bates numbering a .pdf in XI, how can I change the file name to include the bates number AND its name?  I know under file output, there is an option for either/or.  I want both.  Thank you.

    when bates numbering a .pdf in XI, how can I change the file name to include the bates number and the file name?  I know under "file output: it's either/or.  I need both.  Thanks!

    Long ago I wrote a little demo using the touch command. Check out the following thread:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=25128#M25128
    LabVIEW Champion . Do more with less code and in less time .

  • How can i fetch the city name from database according the state name

    If you have any example of Dyamic List box.
    How can i fetch the city name from database according the state name when i select the state name in a dynamic list box.
    Thanks

    When i run the this code it is giving the an exception
    org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.faces.el.EvaluationException: javax.faces.FacesException: javax.faces.FacesException: Can't instantiate class: 'com.mypackage.MyBean'.. class com.mypackage.MyBean : java.lang.NullPointerException
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
         org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
         org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
    root cause
    javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.faces.el.EvaluationException: javax.faces.FacesException: javax.faces.FacesException: Can't instantiate class: 'com.mypackage.MyBean'.. class com.mypackage.MyBean : java.lang.NullPointerException
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
         org.apache.jsp.test_jsp._jspService(test_jsp.java:95)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
         org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
         org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
    root cause
    javax.faces.el.EvaluationException: javax.faces.FacesException: javax.faces.FacesException: Can't instantiate class: 'com.mypackage.MyBean'.. class com.mypackage.MyBean : java.lang.NullPointerException
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:190)
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:143)
         com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:406)
         javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1019)
         javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1046)
         javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:761)
         javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:451)
         com.sun.faces.taglib.html_basic.SelectOneMenuTag.doStartTag(SelectOneMenuTag.java:487)
         org.apache.jsp.test_jsp._jspx_meth_h_005fselectOneMenu_005f0(test_jsp.java:259)
         org.apache.jsp.test_jsp._jspx_meth_h_005fpanelGroup_005f0(test_jsp.java:219)
         org.apache.jsp.test_jsp._jspx_meth_h_005fpanelGrid_005f0(test_jsp.java:189)
         org.apache.jsp.test_jsp._jspx_meth_h_005fform_005f0(test_jsp.java:160)
         org.apache.jsp.test_jsp._jspx_meth_f_005fview_005f0(test_jsp.java:127)
         org.apache.jsp.test_jsp._jspService(test_jsp.java:86)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
         org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
         org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
    root cause
    javax.faces.FacesException: javax.faces.FacesException: Can't instantiate class: 'com.mypackage.MyBean'.. class com.mypackage.MyBean : java.lang.NullPointerException
         com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:292)
         com.sun.faces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:97)
         com.sun.faces.el.impl.NamedValue.evaluate(NamedValue.java:145)
         com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:166)
         com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263)
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:160)
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:143)
         com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:406)
         javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1019)
         javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1046)
         javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:761)
         javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:451)
         com.sun.faces.taglib.html_basic.SelectOneMenuTag.doStartTag(SelectOneMenuTag.java:487)
         org.apache.jsp.test_jsp._jspx_meth_h_005fselectOneMenu_005f0(test_jsp.java:259)
         org.apache.jsp.test_jsp._jspx_meth_h_005fpanelGroup_005f0(test_jsp.java:219)
         org.apache.jsp.test_jsp._jspx_meth_h_005fpanelGrid_005f0(test_jsp.java:189)
         org.apache.jsp.test_jsp._jspx_meth_h_005fform_005f0(test_jsp.java:160)
         org.apache.jsp.test_jsp._jspx_meth_f_005fview_005f0(test_jsp.java:127)
         org.apache.jsp.test_jsp._jspService(test_jsp.java:86)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
         org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
         org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
    root cause
    javax.faces.FacesException: Can't instantiate class: 'com.mypackage.MyBean'.. class com.mypackage.MyBean : java.lang.NullPointerException
         com.sun.faces.config.ManagedBeanFactory.newInstance(ManagedBeanFactory.java:229)
         com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:282)
         com.sun.faces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:97)
         com.sun.faces.el.impl.NamedValue.evaluate(NamedValue.java:145)
         com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:166)
         com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263)
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:160)
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:143)
         com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:406)
         javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1019)
         javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1046)
         javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:761)
         javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:451)
         com.sun.faces.taglib.html_basic.SelectOneMenuTag.doStartTag(SelectOneMenuTag.java:487)
         org.apache.jsp.test_jsp._jspx_meth_h_005fselectOneMenu_005f0(test_jsp.java:259)
         org.apache.jsp.test_jsp._jspx_meth_h_005fpanelGroup_005f0(test_jsp.java:219)
         org.apache.jsp.test_jsp._jspx_meth_h_005fpanelGrid_005f0(test_jsp.java:189)
         org.apache.jsp.test_jsp._jspx_meth_h_005fform_005f0(test_jsp.java:160)
         org.apache.jsp.test_jsp._jspx_meth_f_005fview_005f0(test_jsp.java:127)
         org.apache.jsp.test_jsp._jspService(test_jsp.java:86)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
         org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
         org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
    root cause
    java.lang.ClassNotFoundException: class com.mypackage.MyBean : java.lang.NullPointerException
         java.beans.Beans.instantiate(Unknown Source)
         java.beans.Beans.instantiate(Unknown Source)
         com.sun.faces.config.ManagedBeanFactory.newInstance(ManagedBeanFactory.java:223)
         com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:282)
         com.sun.faces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:97)
         com.sun.faces.el.impl.NamedValue.evaluate(NamedValue.java:145)
         com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:166)
         com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263)
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:160)
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:143)
         com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:406)
         javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1019)
         javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1046)
         javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:761)
         javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:451)
         com.sun.faces.taglib.html_basic.SelectOneMenuTag.doStartTag(SelectOneMenuTag.java:487)
         org.apache.jsp.test_jsp._jspx_meth_h_005fselectOneMenu_005f0(test_jsp.java:259)
         org.apache.jsp.test_jsp._jspx_meth_h_005fpanelGroup_005f0(test_jsp.java:219)
         org.apache.jsp.test_jsp._jspx_meth_h_005fpanelGrid_005f0(test_jsp.java:189)
         org.apache.jsp.test_jsp._jspx_meth_h_005fform_005f0(test_jsp.java:160)
         org.apache.jsp.test_jsp._jspx_meth_f_005fview_005f0(test_jsp.java:127)
         org.apache.jsp.test_jsp._jspService(test_jsp.java:86)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
         org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
         org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
    root cause
    java.lang.NullPointerException
         javax.faces.model.SelectItem.setValue(SelectItem.java:254)
         javax.faces.model.SelectItem.<init>(SelectItem.java:138)
         javax.faces.model.SelectItem.<init>(SelectItem.java:96)
         com.mypackage.MyBean.fillCountryItems(MyBean.java:80)
         com.mypackage.MyBean.<init>(MyBean.java:28)
         sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
         java.lang.reflect.Constructor.newInstance(Unknown Source)
         java.lang.Class.newInstance0(Unknown Source)
         java.lang.Class.newInstance(Unknown Source)
         java.beans.Beans.instantiate(Unknown Source)
         java.beans.Beans.instantiate(Unknown Source)
         com.sun.faces.config.ManagedBeanFactory.newInstance(ManagedBeanFactory.java:223)
         com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:282)
         com.sun.faces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:97)
         com.sun.faces.el.impl.NamedValue.evaluate(NamedValue.java:145)
         com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:166)
         com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263)
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:160)
         com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:143)
         com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:406)
         javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1019)
         javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1046)
         javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:761)
         javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:451)
         com.sun.faces.taglib.html_basic.SelectOneMenuTag.doStartTag(SelectOneMenuTag.java:487)
         org.apache.jsp.test_jsp._jspx_meth_h_005fselectOneMenu_005f0(test_jsp.java:259)
         org.apache.jsp.test_jsp._jspx_meth_h_005fpanelGroup_005f0(test_jsp.java:219)
         org.apache.jsp.test_jsp._jspx_meth_h_005fpanelGrid_005f0(test_jsp.java:189)
         org.apache.jsp.test_jsp._jspx_meth_h_005fform_005f0(test_jsp.java:160)
         org.apache.jsp.test_jsp._jspx_meth_f_005fview_005f0(test_jsp.java:127)
         org.apache.jsp.test_jsp._jspService(test_jsp.java:86)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
         org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
         org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
         org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)

  • How can we delete the icloud accounts from main website.Iam trying to log in to my account and it says that MAXIMUM NUMBER OF FREE ACCOUNTS ARE ACTIVATED?What can i do guys plz tell me?

    How can we delete the icloud accounts from main website.Iam trying to log in to my account and it says that MAXIMUM NUMBER OF FREE ACCOUNTS ARE ACTIVATED?What can i do guys plz tell me?

    You can't delete an account, you can only stop using it.  If you're getting that error message you won't be able to create a new account on your device.  Your only options are to re-use one of the accounts previously created, or create a new account on a different iOS device or Mac (running OS X Lion or higher), if you have one.

  • How to get the target file name from an URL?

    Hi there,
    I am trying to download data from an URL and save the content in a file that have the same name as the file on the server. In some way, what I want to do is pretty similar to what you can do when you do a right click on a link in Internet Explorer (or any other web browser) and choose "save target as".
    If the URL is a direct link to the file (for example: http://java.sun.com/images/e8_java_logo_red.jpg ), I do not have any problem:
    URL url = new URL("http://java.sun.com/images/e8_java_logo_red.jpg");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Everything is fine, the file name I get is "e8_java_logo_red.jpg", which is what I expect to get.
    However, if the URL is an indirect link to the file (for example: http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719 , which link to a file named JavaSetup6u18-rv.exe ), the similar code return AutoDL?BundleId=37719 as file name, when I would like to have JavaSetup6u18-rv.exe .
    URL url = new URL("http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Do you know how I can do that.
    Thanks for your help
    // JB
    Edited by: jb-from-sydney on Feb 9, 2010 10:37 PM

    Thanks for your answer.
    By following your idea, I found out that one of the header ( content-disposition ) can contain the name to be used if the file is downloaded. Here is the full code that allow you to download locally a file on the Internet:
          * Download locally a file from a given URL.
          * @param url - the url.
          * @param destinationFolder - The destination folder.
          * @return the file
          * @throws IOException Signals that an I/O exception has occurred.
         public static final File downloadFile(URL url, File destinationFolder) throws IOException {
              URLConnection urlC = url.openConnection();
              InputStream is = urlC.getInputStream();
              FileOutputStream fos = null;
              String fileName = getFileName(urlC);
              destinationFolder.mkdirs();
              File localFile = new File(destinationFolder, fileName);
              fos = new FileOutputStream(localFile);
              try {
                   byte[] buf = new byte[1024];
                   int i = 0;
                   while ((i = is.read(buf)) != -1) {
                        fos.write(buf, 0, i);
              } finally {
                   if (is != null)
                        is.close();
                   if (fos != null)
                        fos.close();
              return localFile;
          * Returns the file name associated to an url connection.<br />
          * The result is not a path but just a file name.
          * @param urlC - the url connection
          * @return the file name
          * @throws IOException Signals that an I/O exception has occurred.
         private static final String getFileName(URLConnection urlC) throws IOException {
              String fileName = null;
              String contentDisposition = urlC.getHeaderField("content-disposition");
              if (contentDisposition != null) {
                   fileName = extractFileNameFromContentDisposition(contentDisposition);
              // if the file name cannot be extracted from the content-disposition
              // header, using the url.getFilename() method
              if (fileName == null) {
                   StringTokenizer st = new StringTokenizer(urlC.getURL().getFile(), "/");
                   while (st.hasMoreTokens())
                        fileName = st.nextToken();
              return fileName;
          * Extract the file name from the content disposition header.
          * <p>
          * See <a
          * href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html">http:
          * //www.w3.org/Protocols/rfc2616/rfc2616-sec19.html</a> for detailled
          * information regarding the headers in HTML.
          * @param contentDisposition - the content-disposition header. Cannot be
          *            <code>null>/code>.
          * @return the file name, or <code>null</code> if the content-disposition
          *         header does not contain the filename attribute.
         private static final String extractFileNameFromContentDisposition(
                   String contentDisposition) {
              String[] attributes = contentDisposition.split(";");
              for (String a : attributes) {
                   if (a.toLowerCase().contains("filename")) {
                        // The attribute is the file name. The filename is between
                        // quotes.
                        return a.substring(a.indexOf('\"') + 1, a.lastIndexOf('\"'));
              // not found
              return null;
         }

  • How can I get specific files back from my Time Machine backup?

    I wanted to make a fresh install on my MacBook Pro, in order to only have Java 8 instead of any older Java versions. So far so good. But now I want to get specific files/libraries from my external backup (USB):
    One Parallels Virtual Machine
    My old mail
    My iPhoto Library
    I don't need any settings for these, since I can easily configure them again.
    I already used the Migration Assistent to restore all apps.
    How can I get specific data back from the backup without restoring all stuff that I don't want anymore?
    I'm now working on a new account on the fresh system, called 'Admin'. My old account was called 'Hans' (or 'hans') and I'd like to create such an account again for all my tasks.
    Hans

    How can I get specific data back from the backup without restoring all stuff that I don't want anymore?
    I'm now working on a new account on the fresh system, called 'Admin'. My old account was called 'Hans' (or 'hans') and I'd like to create such an account again for all my tasks.
    You will want to add the same User account(s) which hold the data you want to restore. So you will want to add a User account of 'Hans or hans'. Check your Time Machine back up drive to see how the User account is labeled (Hans or hans). Navigate to the Users folder and see how it's labeled.
    You can then use your Time Machine back up drive and navigate to the User Home folder to copy its data over (e.g. contents from Documents, Downloads, Music, Pictures, etc.). Repeat for other Users.

  • How can i change upload file name?

    hi
    I performed a upload Jsp page by OJSP file access in jdeveloper,and it can upload file!
    but i want to change uplaod file name!
    How can i do?
    Any help will be appreciated!
    Thanks
    Jiawei Zhao

    My questions are
    1) when use oreilly package to do file upload , it looks like i line of code is enough to store the upload file in the
    file direction.
    MultipartRequest multi =
            new MultipartRequest(request, dirName, 10*1024*1024); // 10MB
    why some example still use FileOutputStream?
    outs = new FileOutputStream(UPLOADDIR+fileName); 
        filePart.writeTo(outs); 
       outs.flush(); 
      outs.close();
    2) can I rename the file name when I use oreilly package?

  • How can i execute Spaces API in java main class?

    Hi
    I am able to execute Spaces API through portal application. However if i try to execute it in java main class, its throwing an exception
    "SEVERE: java.io.FileNotFoundException: .\config\jps-config.xml (The system cannot find the path specified)"
    oracle.wsm.common.sdk.WSMException: WSM-00145 : Keystore location or path can not be null or empty; it must be configured through JPS configuration or policy configuration override.
    How can i set this path, so that i can execute Spaces API from java main class.
    Need this main class to configure in cron job, to schedule a task.
    Regards
    Raj

    Hi Daniel
    Currently i have implemented create functionality in my portal application using Spaces API, which is working fine. Now the requirement is, i need to implement a "Cron Job" to schedule a task, which will execute to create space(for example once in a week). Cron job will execute only the main method. So I have created java main class, in which I have used Spaces API to perform create space operation. Then it was giving exception.
    Later I understood the reason, as I am executing the Space API with a simple JSE client, its failing since a simple java program has no idea of default-keystore.jks, jps-config.xml, Security Policy. Hence i have included those details in main class. Now I am getting new error,
    SEVERE: WSM-06303 The method "registerListener" was not called with required permission "oracle.wsm.policyaccess"
    For your reference i have attached the code below, please help. How can i use Spaces API in java main method(i mean public static void main(String[] args) by giving all required information.
        public static void main(String[] args) throws InstantiationException,
                                                      GroupSpaceWSException,
                                                      SpacesException {
            Class2 class2 = new Class2();
            GroupSpaceWSContext context = new GroupSpaceWSContext();
            FactoryFinder.init(null);
            context.setEndPoint("http://10.161.226.30/webcenter/SpacesWebService");
            context.setSamlIssuerName("www.oracle.com");
            context.setRecipientKeyAlias("orakey");
            Properties systemProps = System.getProperties();
            systemProps.put("java.security.policy","oracle/wss11_saml_or_username_token_with_message_protection_client_policy");
            systemProps.put("javax.net.ssl.trustStore","C:\\Oracle\\Middleware11.1.7\\wlserver_10.3\\server\\lib\\cacerts.jks");
    systemProps.put("oracle.security.jps.config","C:\\Oracle\\Middleware11.1.7\\user_projects\\domains\\workspace\\system11.1.1.7.40.64.93\\DefaultDomain\\config\\fmwconfig\\jps-config.xml");
            systemProps.put("javax.net.ssl.keyStore",C:\\Oracle\\Middleware11.1.7\\user_projects\\domains\\workspace\\system11.1.1.7.40.64.93\\DefaultDomain\\config\\fmwconfig\\consumer.jks");
            systemProps.put("javax.net.ssl.keyStorePassword", "Test12");
            System.setProperties(systemProps);
            GroupSpaceWSClient groupSpaceWSClient;
            try {
                groupSpaceWSClient = new GroupSpaceWSClient(context);
                System.out.println("URL: " +
                                   groupSpaceWSClient.getWebCenterSpacesURL());
                //delete the Space
                List<String> groupSpaces = groupSpaceWSClient.getGroupSpaces(null);
                System.out.println("GroupSpaces:: " + groupSpaces.size());
            } catch (Exception e) {
    Regards
    Raj

Maybe you are looking for