Do we need a listener class?

I am trying to create a simple page just to display list of values using javaserver faces.I didn't create any application handler and servlet listener class.
Whenever i try to access the page I get this message "The requested resource (/clientList.jsp) is not available." http 404 error.but the file is there
Whether it's compulsary to create application handler and listener class.
any suggestions ?

did you maybe forget to specify the /faces/* prefix within the URL?
You have to configure the faces servlet to a prefix path and specify it within your URLs...

Similar Messages

  • Creating a singleton Event Listener class

    A typical singleton OO design pattern involved a protected (or private)
    no-arg
    constructor and a public instance() method that manages a private static
    variable
    referencing the single instance, internally invoking the no-arg constructor.
    A class designated in web.xml as a <listener> must have a public no-arg
    constructor.
    (from http://e-docs.bea.com/wls/docs61/webapp/app_events.html#178593)
    Anyone thoughts on how to accomplish both goals?
    What I want to do: I'd like to set up a singleton to listen for session
    events.
    Other code will query this one-and-only-one session event listener for
    various
    information. Some of this info I can currently get from the runtime via
    MBeans but
    some I can't, hence my investigation into session event listeners.
    TIA, matt.

    Hi Matt,
    This sounds like a case where you will need to have two classes -- your
    singleton class, and then your session event listener class, which would use
    the singleton class.
    Dennis Munsie
    Developer Relations Engineer
    BEA Support
    "Matt Hembree" <[email protected]> wrote in message
    news:[email protected]..
    A typical singleton OO design pattern involved a protected (or private)
    no-arg
    constructor and a public instance() method that manages a private static
    variable
    referencing the single instance, internally invoking the no-argconstructor.
    >
    A class designated in web.xml as a <listener> must have a public no-arg
    constructor.
    (from http://e-docs.bea.com/wls/docs61/webapp/app_events.html#178593)
    Anyone thoughts on how to accomplish both goals?

  • Mouse class instead of Mouse Listener class?

    In my previous post, I mentioned about the mouse position checking. I would like to have a Mouse class that has a getX() and getY() so I can call anytime to find where the mouse is even the mouse is not moved, instead of having it in all Listener classes. Is there any way for me to get the mouse's x and y? Since if I want to know where is the mouse, I need to use MouseEvent e within any mouseXXXX() methods. Any hints?
    Many thanks,
    Andy

    Hi Andy,
    Here's a starter for ten. It uses listeners but I don't see a way round that as I can't find (nor imagine) any classes that track the mouse position. If there was such another class then it would probably be called a listener as that's what it does - listen to where the mouse pointer is.
    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseMotionAdapter;
    import javax.swing.*;
    public class MouseTracker extends JFrame {
         private JLabel mx = new JLabel("xx");
         private JLabel mon = new JLabel("ukn");
         private JLabel my = new JLabel("yy");
         MouseTracker(){
              setTitle("MouseTracker");
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setSize(200,200);
              addMouseListener(new MouseAdapter(){
                   public void mouseEntered(MouseEvent evnt){
                        mon.setText("Mouse at home");
                   public void mouseExited(MouseEvent evnt){
                        mon.setText("Oh, sad, mouse has gone.");
              addMouseMotionListener(new MouseMotionAdapter(){
                   public void mouseMoved(MouseEvent evnt){
                        mx.setText(Integer.toString(evnt.getX()));
                        my.setText(Integer.toString(evnt.getY()));
              Container cp = getContentPane();
              cp.add(mx, BorderLayout.NORTH);
              cp.add(mon);
              cp.add(my, BorderLayout.SOUTH);
              show();
         public static void main(String[] a){
              MouseTracker t = new MouseTracker();
    }I've used JLabels to illustrate the ability to determine where the mouse is, even if it's not moving.
    Regards
    sjl

  • External Listener Classes

    Hello,
    I have some quires about the Externer Listener classes. They are:
    1. Can one listener classes have two(2) Port numbers to listen
    2. If i had made a external listener classes as a service object and made
    for Load Balance then do External Listener object listens on different port
    number's.
    Thanks in Advance
    prabhu
    FREE Email for ALL! Sign up at http://www.mail.com

    is Class1 even defined in your main swf?
    if that class is defined in the external swf, you need to use the applicationDomain of your loaded swf to access that class.  for example, in your complete listener:
    var loadedAppDomain:ApplicationDomain = e.target.content.loaderInfo.applicationDomain;  // where e is your complete event
    var C1:Class = loadedAppDomain.getDefinition("Class1") as Class;
    check (objectsList[0] is C1)

  • JMS Listener Class Not found

    Hi
    I got the following error when starting weblogic 8.1 server:
    ####<Jul 14, 2004 5:24:15 PM PDT> <Notice> <Security> <sjcpc044> <myserver> <Thread-1> <<WLS Kernel>> <> <BEA-090082> <Security initializing using security realm myrealm.>
    ####<Jul 14, 2004 5:24:15 PM PDT> <Notice> <WebLogicServer> <sjcpc044> <myserver> <Thread-1> <<WLS Kernel>> <> <BEA-000327> <Starting WebLogic Admin Server "myserver" for domain "cdrdomain">
    ####<Jul 14, 2004 5:24:20 PM PDT> <Error> <JMS> <sjcpc044> <myserver> <Thread-1> <<WLS Kernel>> <> <BEA-040371> <JMSServer "JMSServer-0" JMS Server Session Pool is inavlid and has not been started "CMSessionPool". Exception is "weblogic.jms.common.ConfigurationException: Listener class, com.carescience.jms.CMMsgListener, not found".
    weblogic.jms.common.ConfigurationException: Listener class, com.carescience.jms.CMMsgListener, not found
    at weblogic.jms.backend.BEServerSessionPool.setListener(Ljava.lang.String;)V(BEServerSessionPool.java:283)
    at weblogic.jms.backend.BEServerSessionPool.initialize()V(BEServerSessionPool.java:220)
    at weblogic.jms.backend.BEServerSessionPool.<init>(Ljava.lang.String;Lweblogic.jms.common.JMSID;Lweblogic.jms.backend.BackEnd;Lweblogic.management.configuration.JMSSessionPoolMBean;)V(BEServerSessionPool.java:178)
    at weblogic.jms.backend.BackEnd.createServerSessionPools()V(BackEnd.java:792)
    at weblogic.jms.backend.BackEnd.resume()V(BackEnd.java:1314)
    at weblogic.jms.JMSService.addJMSServer(Lweblogic.management.configuration.JMSServerMBean;)V(JMSService.java:2241)
    at weblogic.jms.JMSService.addDeployment(Lweblogic.management.configuration.DeploymentMBean;)V(JMSService.java:2012)
    at weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(Lweblogic.management.configuration.DeploymentMBean;)Z(DeploymentTarget.java:330)
    at weblogic.management.mbeans.custom.DeploymentTarget.addDeployments(Ljava.util.List;)V(DeploymentTarget.java:590)
    at weblogic.management.mbeans.custom.DeploymentTarget.updateServerDeployments()V(DeploymentTarget.java:568)
    at weblogic.management.mbeans.custom.DeploymentTarget.updateDeployments()V(DeploymentTarget.java:240)
    at COM.jrockit.reflect.NativeMethodInvoker.invoke0(ILjava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Native Method)
                at COM.jrockit.reflect.NativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
                at COM.jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
                at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
                at weblogic.management.internal.DynamicMBeanImpl.invokeLocally(Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(DynamicMBeanImpl.java:711)
                at weblogic.management.internal.DynamicMBeanImpl.invoke(Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(DynamicMBeanImpl.java:690)
                at weblogic.management.internal.ConfigurationMBeanImpl.invoke(Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(ConfigurationMBeanImpl.java:476)
                at com.sun.management.jmx.MBeanServerImpl.invoke(Ljava.lang.Object;Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(MBeanServerImpl.java:1557)
                at com.sun.management.jmx.MBeanServerImpl.invoke(Ljavax.management.ObjectName;Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(MBeanServerImpl.java:1525)
                at weblogic.management.internal.RemoteMBeanServerImpl.private_invoke(Ljavax.management.ObjectName;Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(RemoteMBeanServerImpl.java:947)
                at weblogic.management.internal.RemoteMBeanServerImpl.invoke(Ljavax.management.ObjectName;Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(RemoteMBeanServerImpl.java:908)
                at weblogic.management.internal.MBeanProxy.invoke(Ljava.lang.String;[Ljava.lang.Object;)Ljava.lang.Object;(MBeanProxy.java:946)
                at weblogic.management.internal.MBeanProxy.invokeForCachingStub(Ljava.lang.String;[Ljava.lang.Object;)Ljava.lang.Object;(MBeanProxy.java:481)
                at weblogic.management.configuration.ServerMBean_Stub.updateDeployments()V(ServerMBean_Stub.java:7271)
                at weblogic.management.deploy.slave.SlaveDeployer.updateServerDeployments()V(SlaveDeployer.java:1210)
                at weblogic.management.deploy.slave.SlaveDeployer.resume()V(SlaveDeployer.java:362)
                at weblogic.management.deploy.DeploymentManagerServerLifeCycleImpl.resume()V(DeploymentManagerServerLifeCycleImpl.java:229)
                at weblogic.t3.srvr.SubsystemManager.resume()V(SubsystemManager.java:131)
                at weblogic.t3.srvr.T3Srvr.resume()V(T3Srvr.java:964)
                at weblogic.t3.srvr.T3Srvr.run([Ljava.lang.String;)I(T3Srvr.java:359)
                at weblogic.Server.main([Ljava.lang.String;)V(Server.java:32)
    >
    Here is the how the ListenerClass is set up for JMSSessionPool in config.xml. The com.carescience.jms.CMMsgListener class file is in cia.ear deployed as application for this domain.
        <JMSServer Name="JMSServer-0" Store="jmsq" Targets="myserver">
            <JMSSessionPool
                ConnectionFactory="com.carescience.jms.ConnectionFactory"
                ListenerClass="com.carescience.jms.CMMsgListener"
                Name="CMSessionPool" SessionsMaximum="3">
                <JMSConnectionConsumer
                    Destination="com.carescience.jms.CMTopic" Name="CMConnectionConsumer"/>
            </JMSSessionPool>
            <JMSTopic DestinationKeys="MDSDESTKEY"
                JNDIName="com.carescience.jms.CMTopic" Name="CMTopic"/>
        </JMSServer>
        <Application Name="_appsdir_cia_ear"
            Path="C:\bea81\user_projects\domains\cdrdomain\applications\cia.ear"
            StagedTargets="myserver" StagingMode="stage" TwoPhase="true">
            <EJBComponent Name="ejb_exchange.jar" Targets="myserver" URI="ejb_exchange.jar"/>
            <EJBComponent Name="heartbeat.jar" Targets="myserver" URI="heartbeat.jar"/>
            <WebAppComponent Name="cia" Targets="myserver" URI="cia.war"/>
            <WebAppComponent Name="axis" Targets="myserver" URI="axis.war"/>
        </Application>
    I know we can avoid to the error by adding the jar file containing this class to the class path. But is there any other way?
    Best Regards,
    Kelvin Zheng                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    You could double-check in the JMS newsgroup, but I'm pretty sure that a statically configured listener like this would have to be in the classpath.
    If possible, I'd encourage you to consider using a MDB instead. That could be in your EAR file instead.
    -- Rob

  • File does not Upload !   Error in the listener class com.sap.ip.portal...

    Hello.
    Recently, I Add a New Server Node on Java Central Instance.
    And Java Program Upload on Portal, then following error occured.
    Error in the listener class com.sap.ip.portal.admin.portalanywhere.QueryHandler during the process of
    handleTopic
    Original server node can upload successfully.
    But, An error happens in New Additional node.
    Please tell me way to resolve the error.
    Regards.
    Edited by: Masashi Fujita on Dec 24, 2008 5:29 AM
    Edited by: Masashi Fujita on Dec 25, 2008 7:20 AM

    Hi Masashi Fujita,
    Check this Link for Uploading and Downloading files using Web Dynpro Java.
    [Uploading and Downloading Files in Web Dynpro Java|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71]
    [Upload Files Using Web Service in Web Dynpro Java Application|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c0d9336b-b4cf-2910-bdbf-b00d89bd2929]
    [Uploading and Downloading Files in Web Dynpro Tables|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0e10426-77ca-2910-7eb5-d7d8982cb83f]
    Thanks & Regards,
    Sharma Kvbk.

  • Error occured in invoking event "contextInitialized()" on listener class co

    Hi All,
    I am working on JSF 1.2 on SAP NetWeaver CE. I am able to execute sample JSF application successfully when NO java program is written in the application. When I write a java program inside the JSF application...I am getting following error. Please let me know how to proceed on this:
    "Application error occurred during the request procession."
    Error occured in invoking event "contextInitialized()" on listener class com.sun.faces.config.ConfigureListener.
    Details:
    java.lang.UnsupportedClassVersionError: Bad version number in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:654)
    at com.sap.engine.boot.loader.ResourceMultiParentClassLoader.loadClassLocal(ResourceMultiParentClassLoader.java:198)
    at com.sap.engine.boot.loader.MultiParentClassLoader.findClassInLoaderGraph(MultiParentClassLoader.java:302)
    at com.sap.engine.boot.loader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:256)
    at com.sap.engine.boot.loader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:228)
    at com.sun.faces.config.ManagedBeanFactoryImpl.getManagedBeanClass(ManagedBeanFactoryImpl.java:227)
    at com.sun.faces.config.ManagedBeanFactoryImpl.scanForAnnotations(ManagedBeanFactoryImpl.java:1130)
    at com.sun.faces.config.ManagedBeanFactoryImpl.<init>(ManagedBeanFactoryImpl.java:156)
    at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:926)
    at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:507)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:402)
    at com.sap.engine.services.servlets_jsp.server.application.WebEvents.contextInitialized(WebEvents.java:74)
    at com.sap.engine.services.servlets_jsp.server.deploy.ApplicationThreadInitializer.run(ApplicationThreadInitializer.java:198)
    at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:152)
    at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:247)
    Rgds,
    Pathan

    Pathan wrote:
    java.lang.UnsupportedClassVersionError: Bad version number in .class fileThe Java version of the Java compiler used is newer than the Java version of the Java runtime used.
    E.g. compiling with JDK 1.6 and running with JRE 1.5 would cause this error.

  • HT201436 I can't retrieve a voicemail. I need to listen to it again. Please help asap.

    I can't retrieve a voicemail to listen to it again.  It has not been deleted.  I simply need to listen again to retrieve the phone number that was listed as unknown.
    <Subject Edited by Host>

    If it has not been deleted then what is the issue?
    Please explain

  • Server context path in the listener class

    Hi, I have a listener class which sends a notification mail. The mail should contain a URL to a page on the server where this listener class is invoked. How can I construct the absolute URL in the lsitener class?

    Hi Masashi Fujita,
    Check this Link for Uploading and Downloading files using Web Dynpro Java.
    [Uploading and Downloading Files in Web Dynpro Java|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71]
    [Upload Files Using Web Service in Web Dynpro Java Application|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c0d9336b-b4cf-2910-bdbf-b00d89bd2929]
    [Uploading and Downloading Files in Web Dynpro Tables|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0e10426-77ca-2910-7eb5-d7d8982cb83f]
    Thanks & Regards,
    Sharma Kvbk.

  • Unable to add the Listener class in project .

    Hi friends ,
    I'm using deploytool of Sun's AppServer 8.2.
    I'm not abel to add the Eventlistener class in the project.
    In the Help Menu the given following discription to Add the Event Listener call
    Web Application WAR File -> Event Listeners tabbed pane
         1. Click Add to add an event listener to the Event Listener Classes list.
         Locate any event listener classes contained in this WAR file in the drop-down list in the Event Listener Classes      pane.
         (note:There is no any drop-down list in in the Event Listener Classes pane.)
    2. If the event listener class is not in the list, in the General tab, click Edit and to go to the Edit Contents      dialog box where the event listener class can be added to the contents of the WAR file. Upon return the event      listener class will be in the pull-down list.
              (note:But the listener class is present in General tab ,WEB-INF->classes->listeners(In the Contents of the           General tab.))
    How could i resolved this , i mean how to add Event Listener Classes in project ?
    (Same problem while adding error page and filter classes which are also present in the General tab)
    Regards,
    Sachin Warang.

    I suggest using NetBeans IDE 5.5, which integrates easily with various appservers, including Sun Java System Application Server.
    -cheng

  • Listener class not found which is declared in the Connector project.

    Hi friends,
    I have a problem, I have created a new J2ee connector project in eclipse
    and created the classes listener,activatioinspec,resource adapter and worker with the name JCA1. I have created another Message driven bean project with name MDB1.Since iam using EJB2.1, I have not implemented MessageListener instead of that i have implemented the
    listener class which is created in the JCA1 Connector project.In the MDB class i have imported that listener class implemented.
    Iam using application server Jonas, i have declared in ra.xml message listener type, In the MDB1 ejbs ejb-jar also declared messaging type.
    While deploying the MDB1 jonas log says the class listener declared in the JCA1 not found , can any one suggest what is the problem ??, Listerner class is declared in JCA1 Connector.
    Thanks
    Rafel

    Did you read the tutorial from Creator?
    David
    http://www.pricerunner.com/forum/viewtopic.php?t=1659

  • Where to start? Need help with classes

    My question involves those classes he wants us to make. I don't really get the concept of classes, so could someone tell me what they think he wants us to do? And try to explain it to me in terms I might be able to understand. Does that mean for us to use subclasses or use separate files for each class? Or could I do either? I'm so confused :(
    Assignment: Write a program that consists of the classes listed below.
    Player Class: The Player Class consists of at least two elements -- the player name and a list of scores for
    games. The score attribute is not used in Program #3 but will be needed in Program #4. Include in the
    class appropriate accessor and mutator methods for each element in the class. You may have other
    attributes if needed.
    Team Class: The Team class consists of at least 6 elements -- the name of the team and five players from
    the Player class. Include in the class appropriate accessor and mutator methods for each element in the
    class. You may have other attributes if needed.
    Course Syllabus Page 3
    Input3 class: The Input3 class is provided for you. The Input3 class supplies data for your program. The
    Input3 class has a public method called getNextString, which returns a string with the input for your
    program, one after the other. You must use this class to get the data for your program. See Input3.java on
    WebCT to understand the class construction.
    Your program should display the roster of each team in alphabetical order by last name.
    This is the Input3 that he gave us to work with if anyone needs to see it:
    public class Input3
         private String[] input = new String[40];
         private static int StringNum = -1;
         public static final int NUMBER_OF_TEAMS = 3;
         public static final int NUMBER_OF_PLAYERS = 5;
         public Input3()
              //The first six inputs will be for the first team
              input[0] = "LAKERS";
              input[1] = "Kobe Bryant";
              input[2] = "Derek Fisher";
              input[3] = "Shaquille O'Neal";     
              input[4] = "Karl Malone";
              input[5] = "Brian Cook";
              //The next six inputs will be for the second team
              input[6] = "MAVERICKS";
              input[7] = "Antoine Walker";
              input[8] = "Dirk Nowitzki";
              input[9] = "Tony Delk";
              input[10] = "Shawn Bradley";
              input[11] = "Travis Best";
              //The next six inputs will be for the third team
              input[12] = "KNICKS";
              input[13] = "Mike Sweetney";
              input[14] = "Allan Houston";
              input[15] = "Howard Eisley";
              input[16] = "Kurt Thomas";
              input[17] = "Shanon Anderson";
         //This method returns the strings one after the other.
         public String getNextString()
              StringNum++;
              return input[StringNum];
    }<br>
    <br>
    <br>
    Thanks

    You could put the classes in separate files, but it's not necessary. They wouldn't be called 'subclasses' here, as that word is specific to inheritance, which you don't need here. Here's an example of using multiple classes:
    public class MainClass {
        public static void main(String [] args) {
         OtherClass1 oc1 = new OtherClass1(3);
         OtherClass2 oc2 = new OtherClass2("hello");
         System.out.println("" + oc1.getInt());
         System.out.println(oc2.getString());
    class OtherClass1 {
        int someInt;
        public OtherClass1(int i) {
            someInt = i;
        public getInt() {
         return someInt;
    class OtherClass2 {
        String someString;
        public OtherClass2(String s) {
            someString = s;
        public getString() {
            return someString;
    }and like BDLH said above, it's preferred to put them in separate files. Just make sure the file name is EXACTLY the same as the class name, followed by .java

  • Javax.naming.NoInitialContextException: Need to specify class name...

    Hello,
    I am trying to use a Database Connection Pool.
    Here is the test class am using to verify the connection pool:
    public static void main(String[] args) { Connection connection = null; try { InitialContext initialContext = new InitialContext(); DataSource dataSource = (DataSource)initialContext.lookup("jdbc/<alias>"); connection= dataSource.getConnection(); } catch (SQLException e) { //   TODO Auto-generated catch block e.printStackTrace(); } catch (NamingException e) { //   TODO Auto-generated catch block e.printStackTrace(); } Statement stmt = null; try { String query = ""; stmt = connection.createStatement(); ResultSet resultSet = null; query = "SELECT <column> ...'"; resultSet = stmt.executeQuery(query); while(resultSet.next()){ System.out.println(resultSet.getString(<column>)); } stmt.close();   stmt = null; connection.close(); connection = null; } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }finally{ if (stmt != null) {   try {   stmt.close();   } catch (SQLException sqlex) {   // ignore -- as we can't do anything about it here   }   stmt = null;   }   if (connection != null) {   try { connection.close();   } catch (SQLException sqlex) {   // ignore -- as we can't do anything about it here   } connection = null;   } } }
    I get following exception..
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280) at javax.naming.InitialContext.lookup(InitialContext.java:347) at com.internal.test.TestRun.main(TestRun.java:53) java.lang.NullPointerException at com.internal.test.TestRun.main(TestRun.java:66) Exception in thread "main"
    The exception points to
    DataSource dataSource = (DataSource)initialContext.lookup("jdbc/OrderStatus");
    Is this the correct way to test...?
    Thanks
    Srinivas

    java_2006 wrote:
    You can't access a jdbc pool like that (simply with a main method).
    The Database connection pool must be managed by a container (a servlet or application server) like tomcat.
    That is not entirely true but it certainly helps and is generally the only way it is used anyway so one might as well do it.

  • Serializing applet - Listener Classes

    I have a Frame which has a Inner Listener Class which extends KeyAdapter. When I try serializing this Frame using writeObject( Object ) It gives a non-serializble exception on the inner class . Are Inner Classes Serializable. My Inner Class looks as follows
    public class myListener extends KeyAdapter
    public void KeyPressed...
    I get an Exception - myListener not Serializable

    Inner classes exist to avoid cluttering the top-level name space, for their anonymity when no name is required and so forth. If they are member inner classes then they are tied to a given enclosing instance at creation time and must be created in a member context of their enclosing class (or subclass). There is no relation between an inner class and its encloser as far as their class or interface inheritance is concerned, so if you serialise an enclosing class then its inner classes must implement serializable also.
    Hope that helps

  • The new iTunes update gives me no option for a "share" tab on the side bar for me to play home shared music. why? please help i need to listen to beyonce!! plzzz

    The new iTunes update gives me no option for a "share" tab on the side bar for me to play home shared music. why? please help i need to listen to beyonce!! plzzz

    "share tab on the side bar ..."
    iTunes has not had a sidebar for over a year.  You can see one (as iTunes 10 used to show) by doing View > Show Sidebar from iTunes' menu.
    But I'm not sure if that is your issue.  You do not need a sidebar to do home sharing.  Are you running the current iTunes (11.1.3)?  Have you turned on sharing in Preferences?   Have you done File > Turn on Home Sharing?

Maybe you are looking for