Authenticate method in Authenticate class doesn't populate principals in the Subject

Hi,
The authenticate method in the weblogic.security.auth.Authenticate class is supposed to populate the subject with the principal(the authenticated user).I don't see it happening when i call the authenticate method and then when i call subject.getPrincipals() , it returns an empyty set.I'm not sure if i have a problem or is that a bug.If any one has used the authenticate method pls. let me know if it worked fine and what i might be doing wrong.
Thanks in advance
kannan

I have the same problem, have you found a solution?
thanks
/Chriz

Similar Messages

  • WebDynpro Method from a Class Interface?

    Is possible to call a webdynpro method from a class interface that is register in the WDDOINIT of the same WEBDYNPRO component?
    I register my custom webdynpro screen into FPM_OIF_COMPONENT, now when I execute a FPM action my WebDynpro receives the action but ofcourse WDDOINIT doesn't get triggered again. I need to call my webdynpro code in the class interface so I can update my custom screen.
    SAP does that in their standard screen, Can I do that?
    Jason PV

    As Matt pointed out, your questions indicate that you should start from the basics, then as your knowledge enlarges, go and familarize with more advanced concepts of ABAP Objects. Once you feel a bit comfortable with that, go for BADIs and read a bit about that too.
    In my opinion the best start is to read some book, which covers most of ABAP OO concepts. Personally I would recommend [ABAP Objects: ABAP Programming in SAP NetWeaver|http://www.sap-press.com/product.cfm?account=&product=H1934] as I like this author and had his previous book. This would give you strong foundations of what is going on here. Eventually you will often want to refresh some concepts so you have everything you need in one spot (book).
    Of course if want to save some money, simply look for articles/blogs/wikis in SDN or search in Google. There are plenty of these.
    For start I suggest these series of videoblogs [Basic ABAP OO eLearnings|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3414800)ID1160600550DB10016261778120999663End?blog=/pub/wlg/15408]
    This will give you rough idea how the OO design should be done.
    Regards
    Marcin

  • Jar doesn't populate Class-Path from manifest to target .jar

    I have a manifest file with the following content:
    Manifest-Version: 1.0
    Name: webserver.jar
    Main-Class: Acme.Serve.Serve
    Java-Bean: False
    Class-Path: webserver.jar servlet.jarHowever result META-INF/MANIFEST.MF populated by jar in webserver.jar doesn't have Class-Path entry. What's the trick without manual editing MANIFEST.MF in .jar?

    The following extension of the class Bar.java will at least get the information from the jar file.
    package bar;
    import foo.Foo;
    import java.io.File;
    import java.io.IOException;
    import java.util.Iterator;
    import java.util.Map;
    import java.util.Set;
    import java.util.jar.Attributes;
    import java.util.jar.JarFile;
    import java.util.jar.Manifest;
    public class Bar {
      public static void main(String[] argv) {
        try {
          String classpath = Foo.getPath();
          System.out.println("java.class.path=" + classpath);
          if (!new File(classpath).isDirectory()) {
         JarFile f = new JarFile(classpath);
         Manifest mf = f.getManifest();
         Attributes a = mf.getMainAttributes();
         Iterator keys = a.keySet().iterator();
         while (keys.hasNext()) {
           Attributes.Name key = (Attributes.Name)keys.next();
           String value = a.getValue(key);
           System.out.println(key + "=" + value);
        catch (IOException ioe) {
          System.err.println("Error: " + ioe.getMessage());
    }

  • Returning a HashMap K, M from a method of a class typed M

    So, this is what I have. I have a class parameterized for a bean type of a collection it receives, and in a method of the class, I need (would like) to return a HashMap typed as <K, M> as in:
    public class MyClass<M> {
       private Collection<M> beanList;
       public HashMap<K, M> getMap(  /* what do I do here */ );
    }I tried to cheat from looking at the Collections.sort method, knowing it uses the List type in its return type as in:
    public static <T extends Comparable<? super T>> void sort(List<T> list)So, I am trying:
    public HashMap<K, M> getMap(Class<K> keyType)But, it is telling me I need to create class K.
    So... how does the Collections.sort method get away with it and I can't????
    I suppose I could write the method as:
    public HashMap<Object, M> getMap()but became somewhat challenged by my first guess.
    Any ideas... or just go with the HashMap with the untyped key?

    ejp wrote:
    provided K is inferable from the arguments.Or from the assignment context:
    Set<String> empty = Collections.emptySet();
    Otherwise you have to parameterise the class on <K, M>.You may also specifically provide K when you use the method if the context doesn't give the compiler enough information or if you want to override it.
    Example:
    Set<Object> singleton1 = Collections.singleton("Hello"); //error
    Set<Object> singleton2 = Collections.<Object>singleton("Hello"); //fineEdited by: endasil on 14-May-2010 4:13 PM

  • Calling a class's method from another class

    Hi, i would like to know if it's possible to call a Class's method and get it's return from another Class. This first Class doesn't extend the second. I've got a Choice on this first class and depending on what is selected, i want to draw a image on the second class witch is a Panel extended. I put the control "if" on the paint() method of the second class witch is called from the first by the repaint() (first_class.repaint()) on itemStateChanged(). Thankx 4 your help. I'm stuck with this.This program is for my postgraduation final project and i'm very late....

    import java.awt.*;
    import java.sql.*;
    * This type was generated by a SmartGuide.
    class Test extends Frame {
         private java.awt.Panel ivjComboPane = null;
         private java.awt.Panel ivjContentsPane = null;
         IvjEventHandler ivjEventHandler = new IvjEventHandler();
         private Combobox ivjCombobox1 = null;
    class IvjEventHandler implements java.awt.event.WindowListener {
              public void windowActivated(java.awt.event.WindowEvent e) {};
              public void windowClosed(java.awt.event.WindowEvent e) {};
              public void windowClosing(java.awt.event.WindowEvent e) {
                   if (e.getSource() == Test.this)
                        connEtoC1(e);
              public void windowDeactivated(java.awt.event.WindowEvent e) {};
              public void windowDeiconified(java.awt.event.WindowEvent e) {};
              public void windowIconified(java.awt.event.WindowEvent e) {};
              public void windowOpened(java.awt.event.WindowEvent e) {};
         private Panel ivjPanel1 = null;
    * Combo constructor comment.
    public Test() {
         super();
         initialize();
    * Combo constructor comment.
    * @param title java.lang.String
    public Test(String title) {
         super(title);
    * Insert the method's description here.
    * Creation date: (11/16/2001 7:48:51 PM)
    * @param s java.lang.String
    public void conexao(String s) {
         try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
              String url = "jdbc:oracle:thin:system/[email protected]:1521:puc";
              Connection db = DriverManager.getConnection(url);
              //String sql_str = "SELECT * FROM referencia";
              Statement sq_stmt = db.createStatement();
              ResultSet rs = sq_stmt.executeQuery(s);
              ivjCombobox1.addItem("");
              while (rs.next()) {
                   String dt = rs.getString(1);
                   ivjCombobox1.addItem(dt);
              db.close();
         } catch (SQLException e) {
              System.out.println("Erro sql" + e);
         } catch (ClassNotFoundException cnf) {
    * connEtoC1: (Combo.window.windowClosing(java.awt.event.WindowEvent) --> Combo.dispose()V)
    * @param arg1 java.awt.event.WindowEvent
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private void connEtoC1(java.awt.event.WindowEvent arg1) {
         try {
              // user code begin {1}
              // user code end
              this.dispose();
              // user code begin {2}
              // user code end
         } catch (java.lang.Throwable ivjExc) {
              // user code begin {3}
              // user code end
              handleException(ivjExc);
    * Return the Combobox1 property value.
    * @return Combobox
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private Combobox getCombobox1() {
         if (ivjCombobox1 == null) {
              try {
                   ivjCombobox1 = new Combobox();
                   ivjCombobox1.setName("Combobox1");
                   ivjCombobox1.setLocation(30, 30);
                   // user code begin {1}
                   this.conexao("select * from referencia");
                   // user code end
              } catch (java.lang.Throwable ivjExc) {
                   // user code begin {2}
                   // user code end
                   handleException(ivjExc);
         return ivjCombobox1;
    * Return the ComboPane property value.
    * @return java.awt.Panel
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private java.awt.Panel getComboPane() {
         if (ivjComboPane == null) {
              try {
                   ivjComboPane = new java.awt.Panel();
                   ivjComboPane.setName("ComboPane");
                   ivjComboPane.setLayout(null);
                   getComboPane().add(getCombobox1(), getCombobox1().getName());
                   getComboPane().add(getPanel1(), getPanel1().getName());
                   // user code begin {1}
                   // user code end
              } catch (java.lang.Throwable ivjExc) {
                   // user code begin {2}
                   // user code end
                   handleException(ivjExc);
         return ivjComboPane;
    * Return the ContentsPane property value.
    * @return java.awt.Panel
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private java.awt.Panel getContentsPane() {
         if (ivjContentsPane == null) {
              try {
                   ivjContentsPane = new java.awt.Panel();
                   ivjContentsPane.setName("ContentsPane");
                   ivjContentsPane.setLayout(new java.awt.BorderLayout());
                   getContentsPane().add(getComboPane(), "Center");
                   // user code begin {1}
                   // user code end
              } catch (java.lang.Throwable ivjExc) {
                   // user code begin {2}
                   // user code end
                   handleException(ivjExc);
         return ivjContentsPane;
    * Return the Panel1 property value.
    * @return Panel
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private Panel getPanel1() {
         if (ivjPanel1 == null) {
              try {
                   ivjPanel1 = new Panel();
                   ivjPanel1.setName("Panel1");
                   ivjPanel1.setBackground(java.awt.SystemColor.scrollbar);
                   ivjPanel1.setBounds(24, 118, 244, 154);
                   // user code begin {1}
                   // user code end
              } catch (java.lang.Throwable ivjExc) {
                   // user code begin {2}
                   // user code end
                   handleException(ivjExc);
         return ivjPanel1;
    * Called whenever the part throws an exception.
    * @param exception java.lang.Throwable
    private void handleException(java.lang.Throwable exception) {
         /* Uncomment the following lines to print uncaught exceptions to stdout */
         // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
         // exception.printStackTrace(System.out);
    * Initializes connections
    * @exception java.lang.Exception The exception description.
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private void initConnections() throws java.lang.Exception {
         // user code begin {1}
         // user code end
         this.addWindowListener(ivjEventHandler);
    * Initialize the class.
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private void initialize() {
         try {
              // user code begin {1}
              // user code end
              setName("Combo");
              setLayout(new java.awt.BorderLayout());
              setSize(460, 300);
              setTitle("Combo");
              add(getContentsPane(), "Center");
              initConnections();
         } catch (java.lang.Throwable ivjExc) {
              handleException(ivjExc);
         // user code begin {2}
         // user code end
    * Insert the method's description here.
    * Creation date: (11/17/2001 2:02:58 PM)
    * @return java.lang.String
    public String readCombo() {
         String dado = ivjCombobox1.getSelectedItem();
         return dado;
    * Starts the application.
    * @param args an array of command-line arguments
    public static void main(java.lang.String[] args) {
         try {
              /* Create the frame */
              Test aTest = new Test();
              /* Add a windowListener for the windowClosedEvent */
              aTest.addWindowListener(new java.awt.event.WindowAdapter() {
                   public void windowClosed(java.awt.event.WindowEvent e) {
                        System.exit(0);
              aTest.setVisible(true);
         } catch (Throwable exception) {
              System.err.println("Exception occurred in main() of Test");
              exception.printStackTrace(System.out);
    * Insert the type's description here.
    * Creation date: (11/17/2001 1:59:15 PM)
    * @author:
    class Combobox extends java.awt.Choice {
         public java.lang.String dado;
    * Combobox constructor comment.
    public Combobox() {
         super();
         initialize();
    * Called whenever the part throws an exception.
    * @param exception java.lang.Throwable
    private void handleException(java.lang.Throwable exception) {
         /* Uncomment the following lines to print uncaught exceptions to stdout */
         // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
         // exception.printStackTrace(System.out);
    * Initialize the class.
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private void initialize() {
         try {
              // user code begin {1}
              // user code end
              setName("Combobox");
              setSize(133, 23);
         } catch (java.lang.Throwable ivjExc) {
              handleException(ivjExc);
         // user code begin {2}
         // user code end
    * main entrypoint - starts the part when it is run as an application
    * @param args java.lang.String[]
    public static void main(java.lang.String[] args) {
         try {
              java.awt.Frame frame = new java.awt.Frame();
              Combobox aCombobox;
              aCombobox = new Combobox();
              frame.add("Center", aCombobox);
              frame.setSize(aCombobox.getSize());
              frame.addWindowListener(new java.awt.event.WindowAdapter() {
                   public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
              frame.setVisible(true);
         } catch (Throwable exception) {
              System.err.println("Exception occurred in main() of Combobox");
              exception.printStackTrace(System.out);
    * Insert the type's description here.
    * Creation date: (11/17/2001 2:16:11 PM)
    * @author:
    class Panel extends java.awt.Panel {
    * Panel constructor comment.
    public Panel() {
         super();
         initialize();
    * Panel constructor comment.
    * @param layout java.awt.LayoutManager
    public Panel(java.awt.LayoutManager layout) {
         super(layout);
    * Called whenever the part throws an exception.
    * @param exception java.lang.Throwable
    private void handleException(java.lang.Throwable exception) {
         /* Uncomment the following lines to print uncaught exceptions to stdout */
         // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
         // exception.printStackTrace(System.out);
    * Initialize the class.
    /* WARNING: THIS METHOD WILL BE REGENERATED. */
    private void initialize() {
         try {
              // user code begin {1}
              // user code end
              setName("Panel");
              setLayout(null);
              setSize(260, 127);
         } catch (java.lang.Throwable ivjExc) {
              handleException(ivjExc);
         // user code begin {2}
         // user code end
    * main entrypoint - starts the part when it is run as an application
    * @param args java.lang.String[]
    public static void main(java.lang.String[] args) {
         try {
              java.awt.Frame frame = new java.awt.Frame();
              Panel aPanel;
              aPanel = new Panel();
              frame.add("Center", aPanel);
              frame.setSize(aPanel.getSize());
              frame.addWindowListener(new java.awt.event.WindowAdapter() {
                   public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
              frame.setVisible(true);
         } catch (Throwable exception) {
              System.err.println("Exception occurred in main() of java.awt.Panel");
              exception.printStackTrace(System.out);
    * Insert the method's description here.
    * Creation date: (11/17/2001 2:18:36 PM)
    public void paint(Graphics g) {
    /* Here's the error:
    C:\Test.java:389: non-static method readCombo() cannot be referenced from a static context
         System.out.println(Test.lerCombo());*/
         System.out.println(Test.readCombo());

  • Simple enough but... calling a method from another class

    Hi all,
    I know it's simple enough, although I can't see where I'm going wrong for some reason. Basically I've got a class which extends JPanel but when I try to call one of its methods from my main class I get an error. The relevant code (I hope) is:
    Main.java
    import java.awt.BorderLayout;
    import javax.swing.UIManager;
    public class Main extends JFrame implements ActionListener {
         JFrame frame;
         public static JPanel statusBar;
         public Main() {
              // Add a status bar
              statusBar = new StatusBar();
              mainPanel.add( statusBar, BorderLayout.SOUTH );
              setContentPane( mainPanel );
         public static void setStatusBarText( String s ) {
              statusBar.setStatusText("Test");
    StatusBar.java
    import java.awt.Color;
    import javax.swing.SwingConstants;
    public class StatusBar extends JPanel {
         private int barWidth;
         private static JLabel status;
         public StatusBar() {
              super();
              //barWidth = Main.getProgramWidth();
              //setPreferredSize( new Dimension(barWidth,22) );
              setLayout( new FlowLayout( FlowLayout.LEADING ) );
              setBorder( BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(160,160,160) ) );
              status = new JLabel("Test", SwingConstants.LEFT);
              //status.setVerticalAlignment( SwingConstants.CENTER );
              add( status );
         protected void setStatusText( String s ) {
              status.setText( s );
              revalidate();
    }The "statusBar.setStatusText("Test");" call in the main class file doesn't work and I get the error:
    >
    cannot find symbol
    symbol : method setStatusText(java.lang.String)
    location: class javax.swing.JPanel
    statusBar.setStatusText("Test");
    >
    Any ideas what I'm doing wrong? I created an instance of the StatusBar class called statusBar, then I use this to call the setStatusText() method (via statusBar.setStatusText()) which I thought was all correct, then it doesn't work? Even if there's an easier way to do what I want to achieve (i.e. update a JLabel from the 'central' main class file instead of setting the JLabel to static and having every class call it directly), I'd appreciate knowing where I'm going wrong here nonetheless.
    Many thanks,
    Tristan

         public static JPanel statusBar;
         public static void setStatusBarText( String s ) {
              statusBar.setStatusText("Test");
    >
    cannot find symbol
    symbol : method setStatusText(java.lang.String)
    location: class javax.swing.JPanel
    statusBar.setStatusText("Test");
    >The type of variable statusBar is JPanel. That's all the compiler takes into account. It's irrelevant that at some point in the program the type of the object pointed to by this variable is a subclass of JPanel (because at another point it might be an instance of another subclass, or of JPanel itself.

  • Calling a non-static method from another Class

    Hello forum experts:
    Please excuse me for my poor Java vocabulary. I am a newbie and requesting for help. So please bear with me! I am listing below the program flow to enable the experts understand the problem and guide me towards a solution.
    1. ClassA instantiates ClassB to create an object instance, say ObjB1 that
        populates a JTable.
    2. User selects a row in the table and then clicks a button on the icon toolbar
        which is part of UIMenu class.
    3. This user action is to invoke a method UpdateDatabase() of object ObjB1. Now I want to call this method from UIMenu class.
    (a). I could create a new instance ObjB2 of ClassB and call UpdateDatabase(),
                                      == OR ==
    (b). I could declare UpdateDatabase() as static and call this method without
         creating a new instance of ClassB.With option (a), I will be looking at two different object instances.The UpdateDatabase() method manipulates
    object specific data.
    With option (b), if I declare the method as static, the variables used in the method would also have to be static.
    The variables, in which case, would not be object specific.
    Is there a way or technique in Java that will allow me to reference the UpdateDatabase() method of the existing
    object ObjB1 without requiring me to use static variables? In other words, call non-static methods in a static
    way?
    Any ideas or thoughts will be of tremendous help. Thanks in advance.

    Hello Forum:
    Danny_From_Tower, Encephalatic: Thank you both for your responses.
    Here is what I have done so far. I have a button called "btnAccept" created in the class MyMenu.
    and declared as public.
    public class MyMenu {
        public JButton btnAccept;
         //Constructor
         public MyMenu()     {
              btnAccept = new JButton("Accept");
    }     I instantiate an object for MyMenu class in the main application class MyApp.
    public class MyApp {
         private     MyMenu menu;
         //Constructor     
         public MyApp(){
              menu = new MyMenu();     
         public void openOrder(){
               MyGUI MyIntFrame = new MyGUI(menu.btnAccept);          
    }I pass this button all the way down to the class detail02. Now I want to set up a listener for this
    button in the class detail02. I am not able to do this.
    public class MyGUI {
         private JButton acceptButton;
         private detail02 dtl1 = new detail02(acceptButton);
         //Constructor
         public AppGUI(JButton iButton){
         acceptButton = iButton;
    public class detail02{
        private JButton acceptButton;
        //Constructor
        public detail02(JButton iButton){
          acceptButton = iButton;
          acceptButton.addActionListener(new acceptListener());               
       //method
        private void acceptListener_actionPerformed(ActionEvent e){
           System.out.println("Menu item [" + e.getActionCommand(  ) + "] was pressed.");
        class acceptListener implements ActionListener {       
            public void actionPerformed(ActionEvent e) {
                   acceptListener_actionPerformed(e);
    }  I am not able to get the button Listener to work. I get NullPointerException at this line
              acceptButton.addActionListener(new acceptListener());in the class detail02.
    Is this the right way? Or is there a better way of accomplishing my objective?
    Please help. Your inputs are precious! Thank you very much for your time!

  • How to access a method of a class which just known class name as String

    Hi,
    Now I have several class and I want to access the method of these class. But what I have is a String which contain the complete name of the class.
    For example, I have two class name class1and class2, there are method getValue in each class. Now I have a String containing one class name of these two class. I want to access the method and get the return value.
    How could I do?
    With Class.forName().newInstance I can get a Object. but it doesn't help to access and execute the method I want .
    Could anybody help me?
    Thanks

    Or, if Class1 and Class2 have a common parent class or interface (and they should if you're handling them the same way in the same codepath)...Class c = Class.forName("ClassName");
    Object o = c.newInstance(); // assumes there's a public no-arg constructor
    ParentClassOrInterface pcoi = (ParentClassOrInterface)o;
    Something result = pcoi.someMethod(); Or, if you're on 5.0, I think generics let you do it this way: Class<ParentClassOrInterface> c = Class.forName("ClassName");
    // or maybe
    Class<C extends ParentClassOrInterface> c = Class.forName("ClassName");
    ParentClassOrInterface pcoi = c.newInstance();
    Something result = pcoi.someMethod();

  • To access a method frm a class derived frm a base class with the same name

    Here' s an example:-
    class TestA {
    public void start() {
    System.out.println("TestA");
    class TestB extends TestA {
    public void start() {
    System.out.println("TestB");
    }In main method I do this:-
    TestA testA = new TestA();
    TestB testB = new TestB();
    ((TestA)testB).start();Output :-
    TestB.
    Now when i define the method as static :-
    class TestA {
    public static void start() {
    System.out.println("TestA");
    class TestB extends TestA {
    public static void start() {
    System.out.println("TestB");
    }Then output is :-
    TestA.
    Can anyone let me know that when i say ((TestA)testB).start(); i.e i am type casting TestB obect to it base call then TestA should be printed but it doesn't print but when i declare method as static is does print TestA.
    Thanks,
    Heena

    >
    >
    Secondly, when i say ((TestA).testB).start(); output is TestB. But when i define start() method as static output is TestA. I need clarity for the same.In the static case, all that the compiler is interested in is the class of the expression before the ".". Because you've put in an explicit cast the type of expression is assumed to be TestA the compiler doesn't know what kind of object will actually be referenced at runtime. In the static case which method is called is determined at compile time.
    In the instance method case what determines the method called is determined the class of the actual, run time, value of the expression, and despite your cast, the actual value is still a reference to a TestB instance, so the TestB method is called. In the instance case which method called is determined at run time.

  • Trying to understand methods - calling methods within own class - help

    I'm trying to write a simple program to search for letters in a string. I'm having a ton op problems; java seems so complicated with a lot of rules.
    The main problem I'm having (for now) is calling a method within the same class as main.
    import java.io.*;
    class LookForLetters{
        public static void main(String[] args)
         int i = 0;     
         int j = 0;
         int l = 0;
         int m = 0;
         String question1 = "Enter the line to be searched"; 
         String question2 = "Enter the line to be searched";       
         returnResponse stringtosearch = new returnResponse(question1); // here's where my problem is
            char[] chartosearch = stringtosearch.toCharArray();
         returnResponse letterstofind = new returnResponse(question2);
            char[] chartofind = letterstofind.toCharArray();     
         int findlength = chartosearch.length();
         int searchlength = chartofind.length();
         int[] k = new int[searchlength];
         for(i = 0; i < findlength; i++)
             for(j = 0; j < searchlength; j++)   
              if(chartosearch[i] == chartofind[j])
                  k[l] = i;
                  l++;
                  System.out.print("T");
             System.out.print(i + " " + l);
                if(l == 0)
                    System.out.print(chartofind[i] + " is the not in the sentence.");
                    System.out.println();       
                else
                    System.out.print(chartofind[i] + " is the ");
                 for(m = 0; m < l; m++)
                     System.out.print(k[l] + " ");
                    System.out.print("letter of your sentence");
                    System.out.println();
                    l = 0;
        public String returnResponse(String question){
         String response = " ";
         System.out.print(question);
         try
             InputStreamReader isr = new InputStreamReader(System.in);
                BufferedReaderbr = new BufferedReader(isr);
             response = br.readLine();            
         catch(IOException e)
             System.out.print("error");
         return response;
    }The compiler says that it can't find the returnResponse method. when I try to instantiate the whole class, it says the package is not included. Please help.

    JoachimSauer wrote:
    DaneWKim wrote:
    thank you very much for your response. I'm sure it's obvious that I'm really confused. I'm used to C and assembly programming, so the OO concepts are really foggy.That particular line doesn't even deal with any OO concept. But the fact that you already know C helps me give a (hopefully) more useful answer:
    What is the return type of the method you're trying to call?
    What is the type of the variable you want to assign the return value to?
    Are those compatible? Or even more general: do they both exist?I changed it to:
            String stringtosearch = returnResponse(question1);
            char[] chartosearch = stringtosearch.toCharArray();
         String letterstofind = returnResponse(question2);
            char[] chartofind = letterstofind.toCharArray();I guess I'm getting confused with medthods, class and types. There's a whole host of new vocabulary and rules with OO and java that have me a bit confused. I appreciate your help.

  • Method declaration in Class

    Hi Experts,
             In Classes and Methods i got one requirement like this , Please respond it.
    I have to create the method , where class is already defined(ZCL_CONFIGURABLE_ITEM )
    Create Method:  IS_SEQUENCE_NOT_TO_PRINT .
    Class name :ZCL_CONFIGURABLE_ITEM
    They had given me example logic also. But iam not able to do this because i have no idea on classes and methods.
    Please see this example and respond me .
    Create Method:  IS_SEQUENCE_NOT_TO_PRINT .  This must be a value method in class ZCL_CONFIGURABLE_ITEM , passing document number VBDKR-VBELN that returns a parameter value: X = True, Blank = false.
    GET BILLTO_PARTNER customer number for the document (reading VBPA where VBELN = document number VBDKR-VBELN and partner PARVW = ‘RE’ / ‘BP’)Read table KNA1 to get field KNA1-KATR6 where KUNNR equals Billto partner, and fields VBDKR-VKORG, VBDKR-VTWEG, VBDKR-SPART, Store first character of field KNA1-KATR6 in a work field e.g. W_ KATR6.
    Add the entry below to the ZLITERAL table in all clients
    Read the records from ZLITERAL table (reading key1 = C_ZLIT_GENOSYS_KEY, and key2 = C_KATR6_1) where C_KATR6_1 = attribute on class, with value = KATR6_1 .  You must add this attribute on the class.  Populate the internal table L_ZLITERAL_TAB type ZLITERAL_TAB_TYPE.

    Hi,
        You can create the method from the CLASS BUILDER. SE24. There navigate to methods tab and enter you method name. Then select visibility public or private.
    Then click on the parameters button to add parameters to the method. Selec IMPORT, EXPORT or RETURNING parameter for the function.
    Regards,
    Sesh

  • Methods in Intern classes using ActionListener

    As the title said, I have a problem with getting the method in the intern class to work. I want to make an applet that makes an connection to a mySQL-database and van do an edit-action via a JButton. I tried to make that work via an JButton linked to an ActionListener, and then make an intern class for this ActionListener in which the method for the edit action is. However for some reason it doesn't recognize the instance variables that are in the main class. I have made public getters so that can't be the problem.
    second I tried to make the edit action just a normal method in the main class, but how do you then make the button use it?
    Here is the code:
    import java.awt.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.*;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import java.util.*;
    public class Kreta extends JApplet{
         private Connectie con;
         private int menu_id;
         private String naam_gerecht;
         private String prijs;
         private String ingredienten;
         private String recept;
         private JFrame frame;
         private JPanel west;
         private JPanel north;
         private JPanel south;
         private JPanel east;
         private JList overzicht;
         private JTextField n_naam;
         private JTextField n_prijs;
         private JTextField n_gerecht;
         private JTextArea s_recept;
         private JTextArea s_ingredienten;
         public int getID(){
              return this.menu_id;
         public void setID(int menu_id){
              this.menu_id = menu_id;
         public String getNaam_Gerecht(){
              return this.naam_gerecht;
         public void setNaam_Gerecht(String naam_gerecht){
              this.naam_gerecht = naam_gerecht;
         public String getPrijs(){
              return this.prijs;
         public void setPrijs(String prijs){
              this.prijs = prijs;
         public String getIngredienten(){
              return this.ingredienten;
         public void setIngredienten(String ingredienten){
              this.ingredienten = ingredienten;
         public String getRecept(){
              return this.recept;
         public void setRecept(String Recept){
              this.recept = recept;
         public Kreta(int menu_id, String naam_gerecht, String prijs, String ingredienten, String recept){
              this.menu_id = menu_id;
              this.naam_gerecht = naam_gerecht;
              this.prijs = prijs;
              this.ingredienten = ingredienten;
              this.recept = recept;
         public Kreta(){
              con = new Connectie();
              frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         // maak knoppen paneel met listeners, knoppen worden onder elkaar gezet met BoxLayout
              west = new JPanel();
              west.setBackground(Color.darkGray);
              west.setLayout(new BoxLayout(west, BoxLayout.Y_AXIS));
              JButton newButton = new JButton("Nieuw");
              JButton addButton = new JButton("Voeg toe");
              JButton editButton = new JButton("bewerk");
              JButton delButton = new JButton("wis");
              west.add(newButton);
              west.add(addButton);
              west.add(editButton);
              west.add(delButton);
              newButton.addActionListener(new newListener());
              addButton.addActionListener(new addListener());
              editButton.addActionListener(new editListener());
              delButton.addActionListener(new delListener());
         // maak northpanel met 2x textfields
              north = new JPanel();
              n_naam = new JTextField(20);
         // n_naam.setText(menu_id);
              JLabel n_naamlabel = new JLabel("naam");
              n_gerecht = new JTextField(50);
              n_gerecht.setText(naam_gerecht);
              JLabel n_gerechtlabel = new JLabel("naam gerecht");
              n_prijs = new JTextField(6);
              n_prijs.setText(prijs);
              JLabel n_prijslabel = new JLabel("prijs");
              n_naam.add(BorderLayout.NORTH, n_naam);
              n_gerecht.add(BorderLayout.NORTH, n_naamlabel);
              n_prijs.add(BorderLayout.NORTH, n_prijslabel);
              north.add(BorderLayout.NORTH, n_naam);
              north.add(BorderLayout.CENTER, n_gerecht);
              north.add(BorderLayout.SOUTH, n_prijs);
         // maak zuidpanel met 2x JTextArea
              south = new JPanel();
              s_recept = new JTextArea(5,5);
              JLabel s_receptLabel = new JLabel("recept");
              JScrollPane receptScroller = new JScrollPane(s_recept);
              s_recept.setLineWrap(true);
              receptScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
              receptScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
              south.add(receptScroller);
              south.add(BorderLayout.NORTH, s_recept);
              s_ingredienten = new JTextArea(10, 20);
              JLabel s_ingredientenLabel = new JLabel("ingredienten");
              JScrollPane ingrScroller = new JScrollPane(s_ingredienten);
              s_ingredienten.setLineWrap(true);
              ingrScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
              ingrScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
              south.add(ingrScroller);
              south.add(BorderLayout.SOUTH, s_ingredienten);
              // Maak een oostpaneel met JList
              east = new JPanel();
              String[]listEntries = {"1", "2", "3"}; // later moet dit van SQL komen?
              overzicht = new JList(listEntries);
              JScrollPane overzichtScroller = new JScrollPane(overzicht);
              overzichtScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
              overzichtScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
              east.add(overzichtScroller);
              east.add(overzicht);
              frame.getContentPane().add(BorderLayout.WEST, west);
              frame.getContentPane().add(BorderLayout.NORTH, north);
              frame.getContentPane().add(BorderLayout.SOUTH, south);
              frame.getContentPane().add(BorderLayout.EAST, east);
              frame.setSize(500, 500);
              frame.setVisible(true);
         // eind GUI code
         public void leesAction(int menu_id){
                   // met deze methode lees je een kaart door het id op te geven
                   try{
                        Statement st = con.connection.createStatement();
                        String gget;
                        gget = "SELECT DISTINCT * FROM mailingregels WHERE (id = \""+ menu_id + "\");";
                        ResultSet rs = st.executeQuery(gget);
                        rs.next();
                        this.menu_id = rs.getInt(1);
                   // moet int nog omzetten naar String!!
                        this.naam_gerecht = rs.getString(2);
                        this.prijs = rs.getString(3);
                        this.recept = rs.getString(4);
                        this.ingredienten = rs.getString(5);
                        }catch(Exception ex){
                        System.out.println("Kan de gegevens uit de database niet lezen");
                        ex.printStackTrace();
         public void newAction(){
              // creeer een leeg scherm
         public void addAction(){
                                    // voeg gegevens toe aan database
         public void editAction(){
              try{
                   Statement statement = con.connection.createStatement();
                   String sset;
                   sset = "UPDATE afhaalmenus "+
                   "SET menu_id = '" + this.menu_id + "', '"+
                   "naam_gerecht = '" + this.naam_gerecht + "', '"+
                   "prijs = '" + this.prijs + "', '"+
                   "ingredienten = '" + this.ingredienten + "', '"+
                   "recept = '"+ this.recept + "', '"+
                   " WHERE afhaalmenus.id = "+ this.menu_id;
                   statement.executeUpdate(sset);
              }catch(Exception e){
                   System.out.println("edit failed");
         public void delAction(){
              System.out.println("del");
         public class newListener implements ActionListener{
              public void actionPerformed(ActionEvent ev){
                   System.out.println("new");
         public class addListener implements ActionListener{
              public void actionPerformed(ActionEvent ev){
                   System.out.println("add");
         public class editListener implements ActionListener{
              public void actionPerformed(ActionEvent ev){
         public class delListener implements ActionListener{
              public void actionPerformed(ActionEvent ev){
    }I tried to put the method that is under editAction() into the public class of editListener, which would then give this:
    public class editListener implements ActionListener{
              public void actionPerformed(ActionEvent ev){
              try{
                   Statement statement = con.connection.createStatement();
                   String sset;
                   sset = "UPDATE afhaalmenus "+
                   "SET menu_id = '" + this.menu_id + "', '"+
                   "naam_gerecht = '" + this.naam_gerecht + "', '"+
                   "prijs = '" + this.prijs + "', '"+
                   "ingredienten = '" + this.ingredienten + "', '"+
                   "recept = '"+ this.recept + "', '"+
                   " WHERE afhaalmenus.id = "+ this.menu_id;
                   statement.executeUpdate(sset);
              }catch(Exception e){
                   System.out.println("edit failed");
         }then it doesn't recognize the variables any more... How to solve this?
    I hope my problem is clear for everyone... thanks in advance!
    Edited by: boofer on Aug 28, 2008 3:25 AM

    this always points to the object instance the code is in. So in your editListener actionPerformed this point to the action listener instance.
    You need to either explicitly point to the outer class with Kreta.this.menu_id or just leave this out (the compiler then looks to all variables in the current scope and not just the action listener field variables).

  • Methods in a class

    When you add more methods to a class does it increase the amount of memory the Object uses idle, or does it increase the creation time of an object?
    I'm talking around 6000 lines of code, and i was just wondering if it would be better to add all related method inside the class or to make a static class that takes one of the objects as an argument and performs the actions on it.
    Thanks.

    Peter__Lawrey wrote:
    Ok, the class is stored as one file and loading the class causes it to be unpacked (if required) and validated.
    However, if you have a corrupt method, (and I have written a few with ASM) that corruption won't be detected until you call the method. e.g. illegal instructions.
    The points is some loading occurs when the class is first used, but there is additional work which occurs when the method is called for the first time. I suspect the later is more significant for a larger method.Well, but that's not really performance-relevant. What you mean sounds to me like a simple run-time failure during the actual execution of the method. The statements were loaded but not executed, hence the fault remains unnoticed. It doesn't sound to me like there's any loading or verification work prior to invoking a method the first time (and it also wouldn't matter with regards to the overall amount of methods in a class), but then, I never implemented a JVM.

  • Final method and final class

    What is final method and final class in abap objects.

    ejp wrote:
    Since that doesn't work--or would overyy complex to implement... would be impossible to implement. Once the method-local copy goes out of existence, ipso facto it can never be changed. This is the whole point.I consider it impossible too, but I'm not a language/compiler/runtime expert, so I allowed for the possibility that there could be some way to do it--e.g. local variables that are references in inner classes live on the heap instead of the stack, or something. My point isn't that it's possible, just that if it were somehow to be done, it would by ugly, so we may as well consider it impossible--it just ain't gonna happen.
    we go with the logic, "Okay, we need to copies, but keeping them in sync is a nightmareNo, it is +meaningless.+No, it's not meaningless. If we have the two copies, and they're not final, then after the inner object is created, the method can continue running, and either the method or the inner object could modify its copy. As far as our code knows, it's the same variable, so there'd have to be some way to keep them in sync. That's either impossible or undesirably complex--like the above, it doesn't matter which--so it's final in order to get past the issue of keeping the copies in sync.

  • Why do we need private static method or member class

    Dear java gurus,
    I have a question about the use of private and static key words together in a method or inner class.
    If we want to hide the method, private is enough. a private static method is sure not intended to be called outside the class. So the only usage I could see is that this private static method is to be called by another static method. For inner class, I see the definition of Entry inner class in java.util.Hashtable, it is static private. I don't know why not just define it as private. Could the static key word do anything better.
    Could anybody help me to clear this.
    Thanks,

    What don't you get? Private does one thing, andstatic does >something completely different.
    If you want to listen to music, installing an airconditioner doesn't help>
    Hi, if the private keyword is the airconditioner, do
    you think you could get music from the static keyword
    (it acts as the CD player) in the following codes:You're making no sense and you're trying to stretch the analogy too far.
    Private does one thing. If you want that thing, use private.
    Static does something completely different and unrelated. If you want that thing, use static.
    If you want both things, use private static.
    What do you not understand? How can you claim that you understand that they are different, and then ask, "Why do we need static if we have private"? That question makes no sense if you actually do understand that they're different.

Maybe you are looking for

  • Create a workflow that pulls data from a list based on a person in the list and emails that person

    I am trying to create a workflow in SharePoint 2010 using SharePoint Designer.  I have a list [ExceptionList] of users each associated with a sponsor.  A sponsor can have multiple users aligned to them.  I need to create a workflow which emails the s

  • ITunes 7 and Games

    I just upgraded to iTunes 7 and purchased a game for my ipod, but when I went to put it on the ipod it was impossible - it is just sitting in my library now. Anyone have similar complaints? I have no idea how to get it on there. The ipod has been upg

  • How do you choose what opens at start up!

    I don't know what my son did, but skype, imovie, messenger and iphoto all open when I turn my computer on. How do I shut it off. I know it is something simple. I just don'w know what it is?

  • JavaFx Lighting Effects : When to Use which ???

    Hi, I know that this question in more design oriented than technical, but still i'm posting this question in this forum . I wanted to start off with javaFx lighting effects and i have found very good examples online . I have seen the implementation o

  • PDF form problem in web dynpro

    Hello Everybody, I have some problem with PDF form in web dynpro application. I have used T layout view set. On top view i put one image. On left view i have tree element. On right side i have all other elements. Right side, different views are displ