Java error: non-static method cannot be referenced from a static context

April 16, 2015

Recently, while writing a java program, I got the classic Java error:
non-static method cannot be referenced from a static context.

No doubt, other young java practitioners have had this error.

Here, I’ve laid out a simple program, with explanations, so that you can avoid the problem.


public class StaticIssues 
    // At top of the class, only declare the global object 	
    // to be seen in the entire class
    objCount theCount = new objCount();

    // do not run any code here, such as:
    // System.out.println ( "top of class" );
    // or 
    // theCount.returnCount();

    // constructor of the class StaticIssues
    public StaticIssues () 
    {   // In Constructor, initialize the objects
        // including the other objects, such as 
        // instances of sub Object objCount

        theCount.initCount ();

        System.out.println ("StaticIssues () Constructor"  );
        // note that this code will run without this constructor
    }  // end constructor

    // code for sub-object objCount 
    // no brackets at the end of this declaration. ie. objCount ()
    public class objCount 
        // declare integer within class
        // not globally

        private int theCount = 0;

        public void initCount ()
            {	theCount = 0;

        public void incrementCount ()
            {	theCount ++;

        public int returnCount()
        {   return theCount;
        }  // end returnCount()

    }  // end class objCount 

    // other methods can use the object
    public void someMethod ()
        // In other methods, use the instance of the object
        // and call the methods of the object

        theCount.incrementCount ();
        System.out.print ( "In someMethod ()." );
        System.out.println ( "  theCount.returnCount() is now: " +
                theCount.returnCount()  );

        // However, do not reference the object itself. ie.
        // objCount.incrementCount ()  ;
        // otherwise, you get the famous:
        // line number of the error, followed by

        // error: non-static method incrementCount() cannot be 
        // referenced from a static context
        // objCount.incrementCount ()  ; 
        // 1 error

    }  // end someMethod ()

    public static void main(String []args) 
        // within main, create object
        StaticIssues objInstance = new StaticIssues ();

        // reference the object.
        System.out.println ( "objInstance.theCount.returnCount () is: " 
                + objInstance.theCount.returnCount () );


        // Note that from the main class 
        // you have to prefix the references by the 
        // object declared in the main class, 
        // here, objInstance
        System.out.println ( "objInstance.theCount.returnCount () is: " 
                + objInstance.theCount.returnCount () );

    }  // end main

}  // end class StaticIssues


StaticIssues () Constructor
objInstance.theCount.returnCount () is: 0
In someMethod ().  theCount.returnCount() is now: 1
objInstance.theCount.returnCount () is: 1

I’m sure that these guidelines will not solve EVERY occurrence of this error. And that there can be improvements to the program. But as I’ve written before, there is nothing a like good design and coding correctly in the first place.

Feel free to use this as a start.

Installing NEO4J on Windows 7

November 7, 2014

Installing and running NEO4J on Windows is a little different from installing it on Linux.

NEO4J has provided two options to install NEO4J on Windows. One version of NEO4J is a dumbed down version that includes the necessary Java, that comes bundled in an .EXE file. The other Windows version comes in a .ZIP file that more closely resembles a Linux installation.

With NEO4J on Linux, a correct version of the Java JDK/SDK is assumed to be installed, but not so on Windows. Java JDK/SDK installations do have a certain learning curve, and required reading, not suitable for some users.

And then there is Java licensing. Apparently, it’s ok to bundle to Java with an executable file. But it’s not ok for Neo4j to redistribute the correct Java JDK/SDK on NEO4J’s download page, and allow users to download it.

If you are serious about NEO4J, you’ll probably want to use the full blown Windows .ZIP version. For one thing, it follows the standard paradigm and navigation. You’ll get the full functionality. And, it’s not that difficult to use. Read the rest of this entry »

Installing Talend Open Studio For Big Data 5.5.1 on Redhat 6.4

September 20, 2014

Recently, Talend Open Studio For Big Data was recommended for me, so I thought I’d try it out.

But as I’ve so often encountered with Java on Linux, the install was a long process, full of java error stacks, google searches, research, trial and error, debugging, forum posts, and so on. Sigh, not again!

Here’s what I did to get Talend Big Data to install and work.  Big errors I encountered are detailed at the bottom.


Talend Open Studio 5.5.1

Talend Open Studio 5.5.1


Download Talend Big Data Software:

Read the rest of this entry »

Installing Gephi On 64 bit Machines

July 8, 2013

The instructions for installing Gephi can be found at:

They seem simple enough. But I found out that on a 64 bit server, it’s really important that you have a full 64/64/64 bit combination. That represents the operating system, Java, and Gephi. Here are some hints to get it right.


Be sure to download the right java file.   Read the rest of this entry »

Installing Oracle Applications R12 On Windows 7

March 15, 2013

Oracle Applications R12 is not certified for installation on Windows 7. The reason seems to be that Apps wants to be on a server that can do lots with domains. This is problematic or not possible with Windows 7, but easily accomplished with Windows Server 2003 or 2008.

But a few years ago, I managed to install Apps on Windows XP, even though XP is not certified either. So, why not Windows 7?

Read the rest of this entry »

What Version of Weblogic Is It?

January 28, 2012

Ever wonder what version of weblogic is on your server? Here is how to find out.


First, set the environment variables in $DOMAIN_HOME

Read the rest of this entry »

%d bloggers like this: