How to invoke a non-static member from a static reference?

Hello JDC
My program consist of several classes. I find it more readable,logic and useful to declare all the methods in all the classes �static� and get access by Class.member().
The problem showed up when I must use a java biuld-in method( as Component.remove ) within my static method , then I receive compile error.
The first alternative is to create the class instance inside the static my static method , the second is to use interface which declare its member as static final. The two ways doesn�t fit to my needs , do anyone know another way?
Thanks in advance
Shay

Hi
im sorry but im not sure what you mean by "OO desgin". i'll appreciate if you'll link me some sources about this , its sound very interesting .
It may be that you are moving to Java from COBOL or >FOTRAN or something and you are not comfortable with >OO philosophy
For example, you can never have two instances of >the same class have different properties. What's the >point of having classes at all if you are going to do it >this way? Java is my first language , you sound very unhappy about the way i ignore the OOP , i think you right in some terms but i need to exam my thinking again and think how can i implements the same ideas in a form of OOP. whenever all those information will come i'll be able to response.
thanks for your reply
Shay Gaghe

Similar Messages

  • How do you extract non consecutive pages from a pdf document. I can highlight in thumbnails but only extract consecutive.

    How do you extract non consecutive pages from a pdf document?
    I see its easy to do it with consecutive pages by highlighting thumbnails then 'extract' but this does not allow for non consecutive pages.
    Thank you

    After highlighting the pages you can drag them and drop them somewhere,
    like on the desktop, and a new file will be created with just those pages.
    If highlighting the pages is not feasible, or too tricky to do, then a
    script can be used where you specify which pages to extract and the script
    extract them to a new file.

  • How do i transfer non-itunes music from ipad to a pc?

    how do i transfer non-itunes music from ipad to a pc?

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • HT1386 How do I transfer NON purchased music from my ipod nano to my itunes library?

    How do you transfer NON purchased music from iPod Nano to itunes library?  I have icloud.

    You need a third-party program like one of those discussed here:
    Recovering your iTunes library from your iPod or iOS device: Apple Support Communities

  • How do you make a static reference to a method?  I've included code.

    I'm sorry but this is a cross post. This should be here but it is also in the 100% pure Java forum. It won't happen again.
    Now...
    Why doesn't this work? How do I use the method add(int a, int b)?
    ERROR - "Can't make static reference to method int add(int, int) in testClass"
    interface testInterface{   
        static String sString = "TESTING";   
        public int add(int a, int b);
    class testClass implements testInterface{
        public int add(int a, int b){
            return a+b;      
        public static void main(String argv[]){
            int sum = add(3,4);    // here's the error
            System.out.println("test");
            System.out.println( sum );   
    }Again, I apologize for the cross post.

    hi,
    this seems to be pretty easy, isn't it?
    Oh c'mon! You try to invoke a non-static method from within a static method. Solution: Create a specific instance of class testClass:
    testClass test=new testClass();
    test.add(3,4);best regards, Michael

  • How can I use non-static  func in  a static func?

    Hello guys,
    I have a func processFiles which is static, i wanna use a func from another class FileData in processFile func and i dnt wanna make processFile non-static, what should i do?
    my code:
    public class Library {
         private FileData file = new FileData();
         public static void main(String[] args){
            try{
                 Library lib = new Library();
                  lib.processFiles(args);
            catch(IOException e)
                 System.err.println("IOException occurred in main.");
                   System.exit(0);
         @SuppressWarnings("unchecked")
         public  static void processFiles(String[] fileNames) throws IOException {
              file.getMaterial();// I get error here;
    class FileData{
        getMaterila() {}
    }

    1) it's not "func", it's "method".
    2) Create a FileData instance and call the method on that
    3) Read the basic tutorials about what "static" means, and put the error message into Google.

  • How can i transfer non purchased music from my iPod classic to iTunes?

    Recently, my laptop died and geek squad was unable to extract files from hard drive. How do I transfer non purchased music (burned cd's) from my ipod classic to itunes on my new laptop? Apple customer support suggested I engage support communities to find out about 3rd party software (not apple) that can accomplish this. Does anyone know of where I can find such software? Please and thank you

    Back when I had to do something like that, I used Copytrans, http://www.copytrans.net/. You might see if they are what you want.
    At worst, you could open the ipod classic in disk mode, locate the music files, copy them to your hard disk (they won't have good names), and just add them to your library. You'll probably lose play counts and *s with that approach, but it should work.

  • How to find first non zero value from the numeric value or string?

    Hiii, Every body
              I have one numeric indicator in which some valuse is coming with the decimal value, lets say 0.00013, now i want to find the first non-zero value from this numeric indicator, then what should i do to do so? i have converted it in the string, but i could not find any method to find first non-zero value from that string or either from the numeric indicator????
          Can you please help me, how to do it? i have attached the vi and write all the description inside.
    Thanks in Advance,
    Nisahnt
    Attachments:
    Find first nonzero.vi ‏20 KB

    Just convert it to an exponential string and take the first character .
    Message Edited by altenbach on 05-10-2006 08:00 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    FisrstNonzeroChar.png ‏3 KB
    FindFirstNonzeroCharacter.vi ‏20 KB

  • How to invoke a method in JApplet from javascript.

    We want to invoke a method in JApplet from javascript.
    with the help Java Plug-in HTML Converter Version 1.3, we have generated OBJECT/EMBED tag for
    the following applet tag.
    <APPLET CODE = "SimpleApplet" WIDTH = 200 HEIGHT = 300 NAME = "simpleApplet"
    MAYSCRIPT = true>
    <PARAM NAME = "p1" VALUE = "v1">
    </APPLET>
    it is given the following code
    <!--"CONVERTED_APPLET"-->
    <!-- CONVERTER VERSION 1.3 -->
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    WIDTH = 200 HEIGHT = 300 NAME = "simpleApplet"
    codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
    <PARAM NAME = CODE VALUE = "SimpleApplet" >
    <PARAM NAME = NAME VALUE = "simpleApplet" >
    <PARAM NAME = MAYSCRIPT VALUE = true >
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
    <PARAM NAME="scriptable" VALUE="false">
    <PARAM NAME = "p1" VALUE = "v1">
    <COMMENT>
    <EMBED type="application/x-java-applet;version=1.3" CODE = "SimpleApplet" NAME =
    "simpleApplet" WIDTH = 200 HEIGHT = 300 MAYSCRIPT = true p1 = "v1" scriptable=false
    pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED></COMMENT>
    </NOEMBED></EMBED>
    </OBJECT>
    <!--
    <APPLET CODE = "SimpleApplet" WIDTH = 200 HEIGHT = 300 NAME = "simpleApplet"
    MAYSCRIPT = true>
    <PARAM NAME = "p1" VALUE = "v1">
    </APPLET>
    -->
    <!--"END_CONVERTED_APPLET"-->
    But, even after trying to invoke method in the JApplet from javascript, it is not being invoked in
    Netscape. it is being invoked from
    IE after changing the scriptable = true. Is there any such parameter to change, to invoke the
    method in JApplet from javascript?
    can anybody give any suggestion?

    hi there,,
    well the same problem exists with my code also, NS fails to call the function from java applet... if u get the answer please mail me on [email protected]

  • How to invoke a bean in WLS from a servlet in JWS

              Hi,
              I have an application where in i am invoking an EJB in WLS from a servlet in JWS.Could any one give me the correct steps to approach this problem.Till now i was using WLS as webserver itself.can i use the same t3 protocol in my client servlet in JWS.I can't use apache webserver b'cos ,my application is to run in windows platform.
              Thanks in advance,
              Ramasubramanian
              

    hi there,,
    well the same problem exists with my code also, NS fails to call the function from java applet... if u get the answer please mail me on [email protected]

  • Help with static and non static references

    Hi all,
    I'm new to Java I'm having some difficulties with accessing non static methods.
    I'm working with Tree data structures and all the interfaces and methods are non-static.
    I have to write a tester main method to create and modify trees but how do I access the non static fields from main which is static?
    Any help would be appreciated
    Thanks.

    Create an Instance for that particular class then call the method using that instance.

  • How do I make a static reference to a method?  Sample Code Included

    Why doesn't this work? How do I use the method add(int a, int b)?
    ERROR - "Can't make static reference to method int add(int, int) in testClass"
    interface testInterface{
        static String sString = "TESTING";
        int add(int a, int b);
    class testClass implements testInterface{
        public int add(int a, int b){
            return a+b;  
        public static void main(String argv[]){
            int sum = add(3,4);    // here's the error
            System.out.println("test");
            System.out.println( sum );
    }

    Why doesn't this work?Because you can't call a non-static method like add (which operates on the object called this) from a static method like main (for which there is no this).
    There are two ways to fix this:
    (1) In main, create a TestClass object, and call add() for that object:
    class TestClass implements TestInterface {
       public int add(int a, int b) {
          return a+b;
       public static void main(String[] args) {
          TestClass testObject = new TestClass();
          int sum = testObject.add(3, 4);
          System.out.println("test");
          System.out.println(sum);
    }(2) Make add() static. This is the preferred approach, because add() doesn't really need a TestClass object.
    class TestClass implements TestInterface {
       public static int add(int a, int b) {
          return a+b;
       // main is same as the original
    }

  • How to invoke a OSB Proxy Service from a Servlet??

    Hi!!
    I'm a begginer in OSB, and right now I have a OSB configuration in production mode. So, using the console test it's very easy to test (doh) my configuration. But now, I have to make a stress test and after read a lot of documentation I did'nt found the way to do that. So I'm trying to do it by using a Servlet, a doPost method in especific, but after a lot of time I can't invoke the proxy service.
    What is the right way to use a proxy service in production mode??
    How can I call it from my servlet??
    How can I send an xml (or any other object, file, text...) as a Request??
    Help please, thank you...
    Edited by: user12116998 on 18-mar-2010 12:40

    If you have your proxy service published as http/soap, then I recommend you to use SoapUI to test it. It can help you with stress test too.

  • How to invoke Web Service in JAVA from CRM 5.0

    Hi.
    I created a Web Service in JAVA. Now I want to invoke it from CRM 5.0
    in ABAP. How to do it? Could someone give me detail step in step?
    Thanks in advance!

    check this weblog by Thomas Jung
    /people/thomas.jung3/blog/2004/11/17/bsp-a-developers-journal-part-xiv--consuming-webservices-with-abap
    Raja

  • How to copy data for certain member from one dimension to another dimension

    Dear ,
    I want to copy data for certain member ("511102") from one dimension to another combinations of dimensions ,
    I have the following combinations for "511102" :
    _("Budget2012","FY12","Working.V01","SAR","BegBalance","1011","G_10","custom Grades")_
    I want to copy "511102"  to "salary"
    -salary have the following dimensions :
    _("Budget2012","FY12","Working.V01","SAR","BegBalance","General group","All grades","General Employees")_
    , I don't know if I could do it by datacopy of cross dimensional , But I don't HOW >>>
    Thanks in advance

    FIX("Budget2012","FY12","Working.V01","SAR","BegBalance","General group","All grades","General Employees")
    "salary"="511102"->"1011"->"G_10"->"custom Grades";
    ENDFIX
    or
    FIX("Budget2012","FY12","Working.V01","SAR","BegBalance")
    DATACOPY "511102"->"1011"->"G_10"->"custom Grades" to "salary"->"General group"->"All grades"->"General Employees";
    ENDFIX
    Key thing in datacopy is to place the dimensions in cross dimension in the same order. Both sides (before and after "TO") should have equal number of dimension members specified.
    Cheers,
    Alp

Maybe you are looking for