Using a method of a class within an action event

Good day.
A beginner question.
It is possible to use within an action event (triggered by a view of the button)
instantiate a class from another java project and use a method?
If it is possible how to do?
Thank you

hi carlos,
yes it is possible. as a reference please have a look at this document How to Reference External JAR Files in Web Dynpro DC in SAP NW Portal 7.3
basically the steps are the same (adding dependency, public parts, etc.) for a ejb or java project.
regards,
christian

Similar Messages

  • Problem using repaint() method from another class

    I am trying to make tower of hanoi...but unable to transfer rings from a tower to another...i had made three classes....layout21 where all componentents of frame assembled and provided suitable actionlistener.....second is mainPanel which is used to draw the rods n rings in paintComponent.....and third is tower in which code for hanoi is available...i had made an object of mainPanel at layoout21 n tower but i m not able to call repaint from tower..gives an error : cannot find the symbol....method repaint in tower.
    code fragments od three classes are:
    LAYOUT21
    class layout21 extends JFrame implements ActionListener
    { private Vector rod1 = new Vector();
    private Vector rod2 = new Vector();
    private Vector rod3 = new Vector();
    private String elem; //comment
    public String r22;
    public boolean in=false;
    public int count=0; //no of times the transfer to other rods performed
    private int r3,rings; // current no of rings
    private JComboBox nor,col;
    private JLabel no;
    private JLabel moved;
    private JLabel no1;
    private JButton start;
    private JButton ref;
    private AboutDialog dialog;
    private JMenuItem aboutItem;
    private JMenuItem exitItem;
    private tower t;
    final mainPanel2 p =new mainPanel2();
    public layout21()
    { t = new tower();
         Toolkit kit =Toolkit.getDefaultToolkit();
    Image img = kit.getImage("java.gif");
    setIconImage(img);
    setTitle("Tower Of Hanoi");
    setSize(615,615);
    setResizable(false);
    setBackground(Color.CYAN);
         JMenuBar mbar = new JMenuBar();
    setJMenuBar(mbar);
    JMenu fileMenu = new JMenu("File");
    mbar.add(fileMenu);
    aboutItem = new JMenuItem("About");
    aboutItem.addActionListener(this);
    fileMenu.add(aboutItem);
    exitItem = new JMenuItem("Exit");
    exitItem.addActionListener(this);
    fileMenu.add(exitItem);
    Container contentPane =getContentPane();
    JPanel bspanel = new JPanel();
    JPanel bnpanel = new JPanel();
    setBackground(Color.CYAN);
         //JComboBox
    nor = new JComboBox();
    nor.setEditable(false);
    nor.addItem("3");
    nor.addItem("4");
    nor.addItem("5");
    nor.addItem("6");
    nor.addItem("7");
    nor.addItem("8");
    nor.addItem("9");
    bspanel.add(nor);
    col = new JComboBox();
    col.setEditable(false);
    col.addItem("BLACK");
    col.addItem("GREEN");
    col.addItem("CYAN");
    bspanel.add(col);
    JLabel tl = new JLabel("Time");
    tl.setFont(new Font("Serif",Font.BOLD,12));
    bspanel.add(tl);
    JTextField tlag = new JTextField("0",4);
    bspanel.add(tlag);
    start =new JButton("Start");
    bspanel.add(start);
    ref =new JButton("Refresh");
    bspanel.add(ref);
    JButton end =new JButton("End");
    bspanel.add(end);
    start.addActionListener(this);
    nor.addActionListener(this);
    col.addActionListener(this);
    ref.addActionListener(this);
    end.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    dispose(); // Closes the dialog
    contentPane.add(bspanel,BorderLayout.SOUTH);
    JLabel count = new JLabel("No of Transfer reguired:");
    count.setFont(new Font("Serif",Font.BOLD,16));
    bnpanel.add(count);
    no = new JLabel("7");
    no.setFont(new Font("Serif",Font.BOLD,16));
    bnpanel.add(no);
    JLabel moved = new JLabel("Moved:");
    moved.setFont(new Font("Serif",Font.BOLD,16));
    bnpanel.add(moved);
    no1 = new JLabel("0");
    no1.setFont(new Font("Serif",Font.BOLD,16));
    bnpanel.add(no1);
    contentPane.add(bnpanel,BorderLayout.NORTH);
    contentPane.add(p,BorderLayout.CENTER);
         String r = (String)nor.getSelectedItem();
    rings = Integer.valueOf(r).intValue();
    p.draw(rings,1) ;
    public void actionPerformed(ActionEvent evt)
    {  Object source = evt.getSource();
    if(source == start)
    r3 = Integer.valueOf((String)nor.getSelectedItem()).intValue();
    p.transfer(false);
    t.initialise(rod1,rod2,rod3,0);
    t.towerOfHanoi(r3);
         //repaint();
         if(source == ref)
    { rod1.removeAllElements() ;
    rod2.removeAllElements() ;
    rod3.removeAllElements() ;
    count=0;
              r3 = Integer.valueOf((String)nor.getSelectedItem()).intValue();
              p.draw(r3,1);
    p.transfer(true);
    no1.setText(""+0);
    p.trans_vec(rod1,rod2,rod3);
    t.initialise(rod1,rod2,rod3,0);
              System.out.println("");
              repaint();
    if(source == nor)
    { JComboBox j = (JComboBox)source;
    String item = (String)j.getSelectedItem();
    int ring1 = Integer.valueOf(item).intValue();
    int a=1;
    for(int i=1;i<=ring1;i++)
    { a = a*2;
    a=a-1;
    no.setText(""+a);
    p.draw(ring1,1);
    repaint();
    if(source == aboutItem)
    {  if (dialog == null) // first time
    dialog = new AboutDialog(this);
    dialog.setVisible(true);
    if(source == exitItem)
    {  System.exit(0);
         if (source==col)
         { JComboBox j = (JComboBox)source;
    String item = (String)j.getSelectedItem();
              repaint();
    TOWER
    class tower extends Thread
    { private Vector rod1 = new Vector();
    private Vector rod2 = new Vector();
    private Vector rod3 = new Vector();
    private int count ;
    private String elem;
    final mainPanel2 z =new mainPanel2();
    public void initialise(Vector r1,Vector r2,Vector r3,int c)
    { rod1 = r1;
    rod2 = r2;
         rod3 = r3;
         count =c;
    public void towerOfHanoi(int rings)
    for(int i=0;i<rings;i++)
    rod1.add(" "+(i+1));
    System.out.println("rod1:"+rod1.toString());
    hanoi(rings,1,2);
    public void hanoi(int m,int i, int j)
    if(m>0)
    { hanoi(m-1,i,6-i-j);
    if(i==1 && j==2 && rod1.isEmpty()==false)
    { count++;
    //no1.setText(""+count);
    elem = (String)rod1.remove(0);
    rod2.add(0,elem);
         //z.trans_vec(rod1,rod2,rod3);
    repaint(); //NOT ABLE TO USE METHOD HERE...WHY??
    //z.hanoi_paint();
    try
              this.sleep(2000);      
              catch (Exception e) { e.printStackTrace() ;  }
    System.out.println(count+". ROD 2:"+rod2.toString());
    if(i==1 && j==3 && rod1.isEmpty()==false)
    { count++;
         //no1.setText(""+count);
         elem = (String)rod1.remove(0);
    rod3.add(0,elem);
    //z.trans_vec(rod1,rod2,rod3);
    repaint();//
    // z.hanoi_paint();
                   try
              this.sleep(2000);      
              catch (Exception e) { e.printStackTrace() ;  }
    System.out.println(count+". ROD 3:"+rod3.toString());
    if(i==2 && j==1 && rod2.isEmpty()==false)
    { count++;
         //no1.setText(""+count);
         elem = (String)rod2.remove(0);
    rod1.add(0,elem);
    //z.trans_vec(rod1,rod2,rod3);
    repaint();
    //z.hanoi_paint();
    try
              this.sleep(2000);      
              catch (Exception e) { e.printStackTrace() ;  }
    System.out.println(count+". ROD 1:"+rod1.toString());
    if(i==2 && j==3 && rod2.isEmpty()==false)
    { count++;     
         //no1.setText(""+count);
         elem = (String)rod2.remove(0);
    rod3.add(0,elem);
    //z.trans_vec(rod1,rod2,rod3);
    repaint();
    //z.hanoi_paint();
    try
              this.sleep(2000);      
              catch (Exception e) { e.printStackTrace() ;  }
    System.out.println(count+". ROD 3:"+rod3.toString());
    if(i==3 && j==1 && rod3.isEmpty()==false)
    { count++;
         //no1.setText(""+count);
    elem = (String)rod3.remove(0);
    rod1.add(0,elem);
    //z.trans_vec(rod1,rod2,rod3);
    repaint();
    //z.hanoi_paint();
         try
              this.sleep(2000);      
              catch (Exception e) { e.printStackTrace() ;  }
    System.out.println(count+". ROD 1:"+rod1.toString());
    if(i==3 && j==2 && rod3.isEmpty()==false)
    { count++;
         //no1.setText(""+count);
    elem = (String)rod3.remove(0);
    rod2.add(0,elem);
    //z.trans_vec(rod1,rod2,rod3);
    repaint();
    //z.hanoi_paint();
    try
              this.sleep(2000);      
              catch (Exception e) { e.printStackTrace() ;  }
    System.out.println(count+". ROD 2:"+rod2.toString());
    hanoi(m-1,6-i-j,j);
    MAINPANEL
    class mainPanel2 extends JPanel //throws IOException
    public Vector line = new Vector();
    public Vector rod11= new Vector();
    public Vector rod22= new Vector();
    public Vector rod33= new Vector();
    public int no_ring;
    public int rod_no;
    String pixel;
    StringTokenizer st,st1;
    int x,y;
    public boolean initial =true;
    public void paintComponent(Graphics g)
    { System.out.println("repaint test");
    bresenham(100,60,100,360);
         bresenham(101,60,101,360);
    bresenham(102,60,102,360);
    bresenham(103,60,103,360);
    bresenham(104,60,104,360);     
    g.setColor(Color.BLUE);
    while(line.size()>0)
    { pixel = (String)line.remove(0);
    st = new StringTokenizer(pixel);
    x = Integer.valueOf(st.nextToken()).intValue();
    y = Integer.valueOf(st.nextToken()).intValue();
    g.drawLine(x,y,x,y);
    bresenham(300,60,300,360);
    bresenham(301,60,301,360);
    bresenham(302,60,302,360);
    bresenham(303,60,303,360);
    bresenham(304,60,304,360);     
    while(line.size()>0)
    { pixel = (String)line.remove(0);
    st = new StringTokenizer(pixel);
    x = Integer.valueOf(st.nextToken()).intValue();
    y = Integer.valueOf(st.nextToken()).intValue();
    g.drawLine(x,y,x,y);
    bresenham(500,60,500,360);
    bresenham(501,60,501,360);
    bresenham(502,60,502,360);
    bresenham(503,60,503,360);
    bresenham(504,60,504,360);     
    while(line.size()>0)
    { pixel = (String)line.remove(0);
    st = new StringTokenizer(pixel);
    x = Integer.valueOf(st.nextToken()).intValue();
    y = Integer.valueOf(st.nextToken()).intValue();
    g.drawLine(x,y,x,y);
    bresenham(0,361,615,361);//used to get a pixel according to algo.. . func not provided
    bresenham(0,362,615,362);
    bresenham(0,363,615,363);
    bresenham(0,364,615,364);
    bresenham(0,365,615,365);     
    while(line.size()>0)
    { pixel = (String)line.remove(0);
    st = new StringTokenizer(pixel);
    x = Integer.valueOf(st.nextToken()).intValue();
    y = Integer.valueOf(st.nextToken()).intValue();
    g.drawLine(x,y,x,y);
    if(initial==true)
    g.setColor(Color.RED);
    for(int i = no_ring;i>0;i--)
    { g.drawLine(100-(i*8),360-(no_ring - i)*10,100+(i*8)+5,360-(no_ring - i)*10);
    g.drawLine(100-(i*8),359-(no_ring - i)*10,100+(i*8)+5,359-(no_ring - i)*10);
    g.drawLine(100-(i*8),358-(no_ring - i)*10,100+(i*8)+5,358-(no_ring - i)*10);
    g.drawLine(100-(i*8),357-(no_ring - i)*10,100+(i*8)+5,357-(no_ring - i)*10);
    g.drawLine(100-(i*8),356-(no_ring - i)*10,100+(i*8)+5,356-(no_ring - i)*10);
    // draw for each rod
    //System.out.println("rod11:"+rod11);
    //System.out.println("rod22:"+rod22);
    //System.out.println("rod33:"+rod33);
         int r1 = rod11.size();
         int r2 = rod22.size();
         int r3 = rod33.size();
    String rd1,rd2,rd3;
    int r11,r12,r21,r22,r31,r32;
    if(initial == false)
         { g.setColor(Color.RED);
         while(rod11.size()>0)
    { r12 = rod11.size()-1;
              rd1 = (String)rod11.remove(r12);
    r11 = Integer.valueOf(rd1).intValue();
    g.drawLine(100-((r11+1)*8),360-(r1 - (r11+1))*10,100+((r11+1)*8)+5,360-(r1 - (r11+1))*10);
    g.drawLine(100-((r11+1)*8),359-(r1 - (r11+1))*10,100+((r11+1)*8)+5,359-(r1 - (r11+1))*10);
              g.drawLine(100-((r11+1)*8),358-(r1 - (r11+1))*10,100+((r11+1)*8)+5,358-(r1 - (r11+1))*10);
              g.drawLine(100-((r11+1)*8),357-(r1 - (r11+1))*10,100+((r11+1)*8)+5,357-(r1 - (r11+1))*10);
              g.drawLine(100-((r11+1)*8),356-(r1 - (r11+1))*10,100+((r11+1)*8)+5,356-(r1 - (r11+1))*10);
         while(rod22.size()>0)
    { g.setColor(Color.RED);
              r22 = rod22.size()-1;
         System.out.println("TEST *************************:"+r22);
              try
         // e.printStackTrace();      
              InputStreamReader isr = new InputStreamReader(System.in);
         BufferedReader br = new BufferedReader(isr)      ;
         br.readLine() ;
         }catch(Exception f) {}
              rd2 = ((String)rod22.remove(r22)).trim();
    r21 = Integer.valueOf(rd2).intValue();
    g.drawLine(300-((r22+1)*8),360-(r2 - (r22+1))*10,300+((r22+1)*8)+5,360-(r2 - (r22+1))*10);
    g.drawLine(300-((r22+1)*8),359-(r2 - (r22+1))*10,300+((r22+1)*8)+5,359-(r2 - (r22+1))*10);
              g.drawLine(300-((r22+1)*8),358-(r2 - (r22+1))*10,300+((r22+1)*8)+5,358-(r2 - (r22+1))*10);
              g.drawLine(300-((r22+1)*8),357-(r2 - (r22+1))*10,300+((r22+1)*8)+5,357-(r2 - (r22+1))*10);
              g.drawLine(300-((r22+1)*8),356-(r2 - (r22+1))*10,300+((r22+1)*8)+5,356-(r2 - (r22+1))*10);
         while(rod33.size()>0)
    { g.setColor(Color.RED);
              r32 = rod33.size()-1;
              rd3 = (String)rod33.remove(r32);
    r31 = Integer.valueOf(rd3).intValue();
    g.drawLine(500-((r32+1)*8),360-(r3 - (r32+1))*10,500+((r32+1)*8)+5,360-(r3 - (r32+1))*10);
    g.drawLine(500-((r32+1)*8),359-(r3 - (r32+1))*10,500+((r32+1)*8)+5,359-(r3 - (r32+1))*10);
              g.drawLine(500-((r32+1)*8),358-(r3 - (r32+1))*10,500+((r32+1)*8)+5,358-(r3 - (r32+1))*10);
              g.drawLine(500-((r32+1)*8),357-(r3 - (r32+1))*10,500+((r32+1)*8)+5,357-(r3 - (r32+1))*10);
              g.drawLine(500-((r32+1)*8),356-(r3 - (r32+1))*10,500+((r32+1)*8)+5,356-(r3 - (r32+1))*10);
    why i m not able to use repaint() method in tower class? from where i can use repaint() method

    i can't read your code - not formatted with code tags
    I have no chance of getting it to compile (AboutDialog class?? p.draw() ??)
    here's a basic routine - add a couple of things to this to demonstrate what is not
    being redrawn
    (compare the readability of below code (using tags) to yours)
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class Testing extends JFrame
      public Testing()
        setSize(400,300);
        setLocation(400,300);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        final DrawPanel dp = new DrawPanel();
        JButton btn = new JButton("Change Text Location/Repaint");
        getContentPane().add(dp,BorderLayout.CENTER);
        getContentPane().add(btn,BorderLayout.SOUTH);
        btn.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ae){
            dp.x = (int)(Math.random()*300);
            dp.y = (int)(Math.random()*150)+50;
            repaint();}});
      public static void main(String[] args){new Testing().setVisible(true);}
    class DrawPanel extends JPanel
      int x = 50, y = 50;
      public void paintComponent(Graphics g)
        super.paintComponent(g);
        g.drawString("Hello World",x,y);
    }

  • Use a method from another class in another package?

    How can I use a method from another class in another package?

    WhiteJ wrote:
    What do you mean by "new keyword?" You posted this previously:
    I tried that, it seems to not be working. I want to use the constructor from the other class. I imported it, using this piece of code:
    import components.FileChooser;
    components.FileChoser();
    Typically if I am going to call a constructor on a class called Fubar, I'd use new to create a new object:
    Fubar myFubar = new Fubar();Incidently, is it a simple typo in your post or are you trying to use a FileChoser object when it should be FileChooser?

  • Forbit use of method forName of Class

    I have some JAVA applications running in iPlanet Application Server (iAS). I need that the connection to database was only by the pool of iAS and nobody can use:
    Class.forName("oracle.jdbc.driver.OracleDriver"); to connect to DB.
    How can forbit use of method forName of Class?

    You can't.

  • Creating user view using 'createView' method of RemoteSession class

    Hi
    I am trying to create a user view using createView method of RemoteSesson class.
    the code is as follows:
    remoteSession = (RemoteSession)SessionFactory.getSession(REMOTE_HOST, ADMIN_ID, encryptedPassword);
    HashMap map = new HashMap();
    map.put("type", "User");
    map.put("viewId", "User");
    GenericObject obj =
    remoteSession.createView("#ID#3DA2A7588B5510DC:-4D08423:10AAD335A14:-7FEE", map);
    I get the following error on the server side:
    WavesetException: Missing object type
    com.waveset.util.WavesetException: Missing object type
         at com.waveset.util.WavesetException.checkBreakpoint(WavesetException.java:366)
         at com.waveset.util.WavesetException.<init>(WavesetException.java:133)
         at com.waveset.rpc.GenericMessageHandler.createView(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.waveset.rpc.GenericMessageHandler.request(Unknown Source)
         at com.waveset.rpc.SimpleRpcHandler.doRequest(SimpleRpcHandler.java:164)
         at com.waveset.rpc.SimpleRpcHandler.doRequest(SimpleRpcHandler.java:128)
         at org.openspml.server.SOAPRouter.doPost(SOAPRouter.java:500)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Thread.java:595)
    Could anyone tell me what is wrong with this code?
    Thanks!

    hi carlos,
    yes it is possible. as a reference please have a look at this document How to Reference External JAR Files in Web Dynpro DC in SAP NW Portal 7.3
    basically the steps are the same (adding dependency, public parts, etc.) for a ejb or java project.
    regards,
    christian

  • Can I use object methods in a class

    I have a class ball and I am in the process of creating it's move method. I want this method to make the ball move depending on certain factors.
    One of these factors being where a bar has been stopped. I have a bar class which extends JProgressBar and when stopped, produces a number. I want this number to be available to my ball class in some way so it can use it to determine how far the ball has to move. The number can be output using its method getValue() but I am unsure how this can be used by another class.
    I doubt this is possible, but I am sure there are ways to achieve what I want. Any help on this subject would be great.

    Methods in one class can call methods defined in another class, subject to access restrictions (public, protected, package-private). This is pretty basic, so you should be able to get the meat of it from your text or tutorial. Look there, or in the following for explanations and examples, and post again if you can't get your code to work.
    http://java.sun.com/docs/books/tutorial/
    http://java.sun.com/learning/new2java/index.html
    http://javaalmanac.com
    http://www.jguru.com
    http://www.javaranch.com
    Bruce Eckel's Thinking in Java
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java

  • Invoking the main() method of a class within another

    Greetings -
    Can someone tell me what happens when you invoke the main() method of a class from within another class?
    I have a third-party class, designed to be invoked from a command line, that I want to invoke from within a separate class. What appears to be happening is that following the successful execution of the third-party class, the invoking class is terminated as well. That's not the intended behavior I had envisioned. ^_^
    Is there a better way than invoking the main() method? I still need the invoking class to continue executing.
    Thanks!

    Navigate yourself around pitfalls related to the Runtime.exec() method

  • How to use protected method of a class in application

    Hi,
      will u please tell me how to use protected method of class in application. (class:cl_gui_textcontrol, method:limit_text)
    Thanks in advance,
    Praba.

    Hi Prabha,
    You can set the maximum number of characters in a textedit control in the CREATE OBJECT statement itself.
    Just see the first parameter in the method . I mean MAX_NUMBER_CHARS. Just set that value to the required number.
    Eg:
    data: edit type ref to CL_GUI_TEXTEDIT.
    create object edit
      exporting
        MAX_NUMBER_CHARS       = 10
       STYLE                  = 0
       WORDWRAP_MODE          = WORDWRAP_AT_WINDOWBORDER
       WORDWRAP_POSITION      = -1
       WORDWRAP_TO_LINEBREAK_MODE = FALSE
       FILEDROP_MODE          = DROPFILE_EVENT_OFF
        parent                 = OBJ_CUSTOM_CONTAINER
       LIFETIME               =
       NAME                   =
      EXCEPTIONS
        ERROR_CNTL_CREATE      = 1
        ERROR_CNTL_INIT        = 2
        ERROR_CNTL_LINK        = 3
        ERROR_DP_CREATE        = 4
        GUI_TYPE_NOT_SUPPORTED = 5
        others                 = 6
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    In this case, the max: number of characters will be set to 10.
    I hope your query is solved.
    Regards,
    SP.

  • How to create an nfs share using the method "CreateShare" of class "MSFT_NfsServerTasks"

    I need to use the "CreateShare" of the wmi class "MSFT_NfsServerTasks" to create a nfs share.
    I am new to wmi. could somebody please guide me to achieve this. thanks in advance.

    let to me rephrase my question. I need to call the MSFT_NfsServerTasks::createmethod to create the nfs share.
    And the syntax for this method is
    uint32 CreateShare(
    [in] string Name,
    [in] string Path,
    [in] string NetworkName,
    [in] string Authentication[],
    [in] boolean UnmappedUserAccess,
    [in] boolean AnonymousAccess,
    [in] sint32 AnonymousUid,
    [in] sint32 AnonymousGid,
    [in] string LanguageEncoding,
    [in] boolean AllowRootAccess,
    [in] string Permission,
    [in] MSFT_NfsSharePermission ClientPermission[],
    [out] MSFT_NfsShare Share
    And to run this method I will be using "IWbemServices::ExecMethod". This method takes the Input parameter object(IWbemClassObject). I managed to add string the parameters in the input parameterobject as,
    IWbemClassObject* pInInst = NULL;:/*some code*/
    VARIANT var;
    var.vt = VT_BSTR;
    var.bstrVal= SysAllocString(L"C:\\share1");
    BSTR ArgPath = SysAllocString(L"Path");
    hRes = pInInst->Put(ArgName, 0, &var, 0);
    But how could I use it for other parameters e.g. string[], MSFT_NfsSharePermission ClientPermission[]etc.

  • Using common methods with abstract classes

    hello everyone, i wanted to know if it is bad practice (i imagine it is) to place methods which will be used by multiple classes (computational methods) in an abstract class and mark them as static. When i do this they are always project wide utility classes which dont need an instantiation. When using any of these methods which are common to a project i can then just use..
    Type result = ClassName.DoStaticMethod(...);Thanks for any input,
    Dori
    Edited by: Sir_Dori on Dec 8, 2008 2:01 AM

    Depends on what the methods are meant to do, but I wouldn't make the class abstract. I would instead declare it to be final and have a private constructor.
    Kaj
    Ps. Take a look at the java.lang.Match class.

  • Using my Method from my Class (clearer explanation)

    I wrote a class called day. With some methods that perform simple operations. Here is a simple one that prints the day of the week:
    public void printDay()
    System.out.print("Day of the week is "+ day);
    My question is:
    How do I call this method in a new program ?

    I wrote a class called day. With some methods that
    perform simple operations. Here is a simple one that
    prints the day of the week:
    public void printDay()
    System.out.print("Day of the week is "+ day);
    My question is:
    How do I call this method in a new program ?Mate, i'm hardly an expert, but what you probably want to do is instantiate an object of your class in the class that will use it. That means, for an object called "myDay" or whatever else:
    Day myDay = new Day();you can then call your method through the object:
    myDay.printDay();hope that's helpful somehow.

  • PowerShell-EWS How to use .Forward Method of EmailMessage Class

    Hello, 
    im new to PowerShell and EWS and would like to know how to forward an E-Mail with the .Forward Method of the EmailMessage Class.
    Is it possible to also forward an Email with an FileAttachment?
    I already have access to the Messages i want to forward but i cant figure out how to .Forward these Messages.
    Thank you for your help
    Greetings 
    Ingo

    >> Is it possible to also forward an Email with an FileAttachment?
    Yes doing a normal forward is EWS should maintain the attachment on the message eg the following would forward the last email in the Mailbox
    $folderid= new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailboxName)
    $Inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid)
    $ivItemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(1)
    $fiItems = $null
    $fiItems = $service.FindItems($Inbox.Id,$ivItemView)
    $messageBodyPrefix = "This is message that was forwarded by using the EWS Managed API";
    $addresses = New-Object Microsoft.Exchange.WebServices.Data.EmailAddress[] 1
    $addresses[0] = "[email protected]";
    $fiItems.Items[0].Forward($messageBodyPrefix, $addresses);
    If your looking to forward the actual message as an attachment you can use something like
    http://gsexdev.blogspot.com.au/2013/07/forwarding-message-as-attachment-using.html
    Cheers
    Glen

  • Type incompatibility error using remove method of ArrayList class

    This method:
    public int removeFromQueue ( int iIndex )
    return queueFeed.remove( new Integer(iIndex) ) ;
    returns a type error after remove saying its found a boolean but is looking for an int. I want to remove the int value in the ArrayList and use it elsewhere.
    Confused.

    if you are trying to remove an element at the particular index say 5
    i.e., is int value = 5 then you get the return as Object that has been removed. Since ArrayList hols all obejcts and not any primitive data types.
    if you are trying to remove the Object say Integer(5) then you get the return as boolean specifying whether it has been sucessfull or not.
    so you can use either of the following as....
    // To remove Integer Object from Queue
    public boolean removeFromQueue ( int iIndex )
    return queueFeed.remove( new Integer(iIndex) ) ;
    // To remove Object from Queue at specific position
    public Integer removeFromQueue ( int iIndex )
    return (Integer)queueFeed.remove( iIndex ) ;
    }

  • Type incompatibility error using'remove' method in ArrayList class.

    This method:
    public int removeFromQueue ( int iIndex )
    return queueFeed.remove( new Integer(iIndex) ) ;
    returns a type error after remove saying its found a boolean but is looking for an int. I want to remove the int value in the ArrayList and use it elsewhere.
    Confused.

    A - Yeah I get it now mate.
    But the API states that the the object is returned:
    "Returns:
    the element that was removed from the list. " i.e my
    integer value that I know is there
    so why does it return a boolean to me. Am I deploying
    incorrectly.no, the method you are calling takes an Object as a parameter
    look in the docs here for the method remove(Object)
    you will see it returns a boolean
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/AbstractCollection.html#remove(java.lang.Object)it is a method inherited from AbstractCollection and is different than
    the method shown in the javadoc for ArrayList that takes an int
    as a parameter.
    A
    hope this helps

  • Help required: Using objects/methods in other classes

    Hi
    Say you have a class that has a private string instance variable and you have a accessor and mutator method for this object in that class.
    You have another class that needs to access this object via the accessor and mutator methods. How do you do this? When I try I only get nullPointerExceptions or Stack Overflows!!! If anyone can provide some code on how to do this successfully then that will be most appreciated. Thanks.

    Kayaman gave you the right answer
    public class MyDataClass {
    private String importantString;
    public void setImpString(String s) {
    importantString = s;
    public String getImpString() {
    return importantString;
    public class MyMainClass {
    public static void main(String[] args) {
    MyDataClass a = new MyDataClass();
    a.setImpString("This is important");
    System.out.println(a.getImpString());
    }Note that he sets the value of the imp string before trying to get it. The nullpointer that you say is probably because you dont do that.
    Also When you aks a question a little humility doesnt hurt.
    You do need a tutorial first.

Maybe you are looking for

  • No Data dropped while trying to deleting Master Data

    Hi All, I recently enhanced a Master Data to include a field and needed to drop the content of the Master Data, then reload.  I try via the InfoObject (right click -> Delete Data) and it would not drop data - Message: Not all master data can be delet

  • Fileshare between my Mac Pro Quad Core Intel Xeon (64-bit) & Power Mac 9600

    I want to make my Power Macintosh 9600/233 (Mac OS 9) a shared computer with my Mac Pro Quad Core Intel Xeon (64-bit)(Mac OS 10.6.6). I am using a Netopia Model 3346N-VGx DSL Ethernet Managed Switch to network with my Samsung printer and the Mac Book

  • IPad 3 USB cable doesn't fit flush in back...normal?

    I notice when I plug the USB cord into my new iPad 3, it's flush in the front but not in the back. In the back, you can see part of the metal sticking out. Is this normal? Hard to believe Apple would not create a better-fitting cord for the iPad's sl

  • BEx queries - one or more SQL statements generated?

    Iu2019m a BusinessObjects man and BEx is new to meu2026When you execute a BEx query against a cube u2013 how does BEx manage that query and what gets send to the backend DB (e.g. Oracle)? I understand the cube is one table in Oracle?, but other table

  • Can't read pdf links on websites

    Hello, can anyone tell me what is the problem? After downloading the latest OS version (OS X 10.7.4), immediately after, I was not able to read pdf links from company websites. Does anyone know what happened and how to fix this?