Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7798159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:55:09+00:00 2026-06-01T23:55:09+00:00

I’ve been programming for years using .NET and I’m taking the plunge into Java

  • 0

I’ve been programming for years using .NET and I’m taking the plunge into Java with some simple starter programs.

I’m having a bit of trouble though…

When I create my start-up class with public void main, the compiler won’t let me instantiate any of the classes I’ve written?

The error I’m getting is “non-static variable _processor cannot be referenced from a static context” where _processor is the object I’m trying to instantiate from the Processor class that I wrote.

The program will compile and run just fine when I change Processor to a static class, but I don’t want to have to make all of my classes static.

Any way around this?

Thanks in advance!

Here’s everything I’ve written. It won’t compile in the current state:

class Lab
{
    public static void main(String[] args)
    {
        Processor proc = new Processor();

        proc.Go();
    }

    private class Processor
    {
        private Random _rand = new Random();

        public void Processor() {}

        public void Go()
        {

        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:55:10+00:00Added an answer on June 1, 2026 at 11:55 pm

    Is Processor an inner class of Lab by any chance? (yes, now that you published your code, my suspicion is confirmed).

    In Java, nonstatic inner classes contain an implicit reference to the containing object of the outer class, so they can’t be instantiated from static context (from your main method).

    So

    • either create an instance of Lab (e.g. myLab), and then call myLab.new Processor(), or
    • declare Processor static (as you did), or
    • turn Processor into a top level class.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have a jquery bug and I've been looking for hours now, I can't
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.