Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Problem Referencing Nested Inner Classes(Eclipse doesn't recognize static inner class inside of another static inner class)
Problem Referencing Nested Inner Classes [message #786644] Mon, 30 January 2012 17:11 Go to next message
Peter Conrey is currently offline Peter ConreyFriend
Messages: 2
Registered: January 2012
Junior Member
I was given a jar file to reference in my project that has the following class/inner class/inner class structure:

package externalJarFile;

public class Job
{
  public static class GlobalVars
  {
    private List<Job.GlobalVars.Variable> variables;
    public List<Job.GlobalVars.Variable> getVariable()
    {
        if (this.variables == null) {
            this.variables = new ArrayList<Job.GlobalVars.Variable>();
        }
        return this.variables;
    }

    public static class Variable
    {
      String name;
      String value;
      public String getName() { return name; }
      public void setName( String name ) { this.name = name; }
      public String getValue() { return value; }
      public void setValue( String value) { this.value= value; }
    }
  }  
}


The problem I'm having is that I need to populate the "Job.GlobalVars" list, but I can't figure out how to reference the "Variables" type. Whenever I add:

import externalJarFile.Job.GlobalVars.Variable;


I get a compilation error that the type "externalJarFile.Job.GlobalVars.Variable" cannot be referenced. How can I create a new "Variable" instance to add to the "GlobalVars.getVariable()" list?

Here's a snippet that I tried (but didn't work):

Job.GlobalVars vars = new Job.GlobalVars();
Job.GlobalVars.Variable v = new Job.GlobalVars.Variable();


I'm concerned that this is an issue with the Eclipse editor as this code works as expected in JDeveloper, but we are trying to move away from JDev for a number of reasons. Any help would be greatly appreciated.

Sincerely,
Peter
Re: Problem Referencing Nested Inner Classes [message #787178 is a reply to message #786644] Tue, 31 January 2012 08:47 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
Which version of Eclipse are you using? I don't get any error with Eclipse 3.7.1.
Re: Problem Referencing Nested Inner Classes [message #787684 is a reply to message #786644] Tue, 31 January 2012 21:40 Go to previous messageGo to next message
Peter Conrey is currently offline Peter ConreyFriend
Messages: 2
Registered: January 2012
Junior Member
I'm using Indigo, SR1 (I think that's 3.7.1). However, if I reference the code directly, it works. The problem occurs if I reference a jar file containing the nested inner classes.
Re: Problem Referencing Nested Inner Classes [message #787783 is a reply to message #787684] Wed, 01 February 2012 00:48 Go to previous messageGo to next message
Eclipse UserFriend
On 1/31/2012 4:40 PM, Peter Conrey wrote:
> I'm using Indigo, SR1 (I think that's 3.7.1). However, if I reference
> the code directly, it works. The problem occurs if I reference a jar
> file containing the nested inner classes.

Are you sure that "externalJarFile" is the true package name? Open up
the jar file itself and verify there is a file:
externalJarFile/Job$GlobalVars$Variables.class

This is the class file that should exist for that class.

--
Thanks,
Rich Kulp
Re: Problem Referencing Nested Inner Classes [message #788047 is a reply to message #787783] Wed, 01 February 2012 09:36 Go to previous message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
It works fine if I reference as a jar file too.
Previous Topic:Old eclipse does not work fine on Windows 7
Next Topic:Refactor rename undo not working
Goto Forum:
  


Current Time: Tue Apr 16 21:12:03 GMT 2024

Powered by FUDForum. Page generated in 0.90825 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top