Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes Query about Inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Query about Inner classes" Watch "Query about Inner classes" New topic

Query about Inner classes

Vinney Shanmugam
Ranch Hand

Joined: Aug 27, 2008
Posts: 104
I have an inner classB inside classA.ClassA public and class B is private.With java 1.4.2 the code is compiled without error and with java 1.5 it is not compiling. In class B there is a string variable c which is used in some method which is not the method of class B.
The error is c is defined in a inaccessible class or interface(only with java 1.5)

Can anyone clear what's wrong in this?
Martijn Verburg

Joined: Jun 24, 2003
Posts: 3275

Can you post your code? It'll be easier for people to explain the cause

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Vinney Shanmugam
Ranch Hand

Joined: Aug 27, 2008
Posts: 104
Originally posted by Martijn Verburg:
Can you post your code? It'll be easier for people to explain the cause

here is the piece of code....

This is in a seprate file, say,

public class ObtainChannel
private static final int MAX_IOR_STRING_LENGTH = 4000;
private static final int MAX_EVENT_CHANNELS = 50;
static EventChannelInfo[] ChannelList = new EventChannelInfo[MAX_EVENT_CHANNELS];
static int NumChannels = 0;

private static class EventChannelInfo
String fullChannelName; //This is giving the error : it's not accesible
String channelName; // "
NamingContext context;// "

EventChannelInfo(String fullChannelName, String channelName, NamingContext context)
this.fullChannelName = fullChannelName;
this.channelName = channelName;
this.context = context;

This is another file, say ( this file is using fullChannelName,channelName,context varaible decalred in above class) and throws the following error, fullChannelName in ObtainChannel.EventChannelInfo is defined
in an inaccessible class or interface

public class ChanAdmin extends Frame

private void startAdmin(int xPosition, int yPosition)
EventChannelHolder eventChannelHolder = new EventChannelHolder();

// Display a dialog to query operator about which event channel
// to administer
IdentifyChannelDialog info = new IdentifyChannelDialog(this, true);
info.setLocation(50, 50);
for (int i=0; i < ObtainChannel.NumChannels; i++)
info.channelChoice.add(ObtainChannel.ChannelList[i].fullChannelName);// It's giving error
if (ObtainChannel.NumChannels == 0) info.channelChoice.setEnabled(false);
int choice = info.channelChoice.getSelectedIndex();

// Get the event channel either from the naming service or from a file
// based object reference.
if (info.fileNameField.getText().length() == 0)
if (ObtainChannel.NumChannels == 0)
// Naming service not available and no event channel IOR provided

// Use naming service to get event channel
if (!ObtainChannel.FromNamingService(
ObtainChannel.ChannelList[choice].context, // It's giving error
ObtainChannel.ChannelList[choice].channelName, // It's giving error
{ // Get Event Channel from IOR stored in a file
if (!ObtainChannel.FromIORFile(orb, eventChannelHolder,

eventChannelObj = eventChannelHolder.value;

// Start a thread for updating statistics periodically
statUpdate = new StatUpdate(this);

// Display the administration window
setLocation(xPosition, yPosition);

I agree. Here's the link:
subject: Query about Inner classes
It's not a secret anymore!