JBuilder successfully compiling a class file that inadvertantly referenced a "count" variable that I never declared anywhere.

Posted on 2006-06-14
Last Modified: 2013-11-23
I'm not a Java whiz kid, but I certainly know enough to have gotten by quite successfully over these past 7 years.  Servlets primarily.  And I still use my 'ole JBuilder 3 environment.   Ok, them's my credentials, so I hope you don't roll your eyes when you read what I'm experiencing...

Inadvertantly, I saw my Jbuilder3 was compiling (successfully, with no errors or warnings) a servlet that contained a reference to a "count" variable that I NEVER declared anywhere. It took me some time to whittle down the mysterious code to the following three files:,, and

I have yet to understand WHY this is happening.  In the Project properties, I am using JDK 1.2 (yes, I know, maybe a bit outdated but it's worked fine for my simple needs all these years).  I have cleared any reference to external Java libraries.  So the code in question is the 3 simple java files below.  Note there are no "import" statements anywhere.  And each time I compile, I've erased all ".class" files from previous compiles, just to be sure "count" is not referenced in some location I'm not aware of (but that wouldn't make sense anyway, because shouldn't "count" be dot-prefixed with the classname it's declared in?  And no, I'm not inheriting from anything (as you can see below).

The odd thing is this...   If I change anything, such as remove one of the files from my package (appropriately named "wierd"), the compiler then picks up on the undeclared "count" line in

One of these days, I'll have to wean myself off JBuilder3 and get into using a copy of JBuilder2005 I have.  But in the mean time, I am perplexed by this!  Simple changes like removing the call to "Dummy1.sillyUselessProcThatReturnsNull();" in the Dummy unit will cause the compiler to finally see that "count" is not known.

90% of the time, I always seem to find the problem myself after posting my question online, so maybe that will happen here!  But in the mean time, if anyone can explain why this is happening....   well, I'd appreciate it.


========= ===========
package wierd;

class BlahBlah  {

  public BlahBlah() {


========= ============
package wierd;

class Dummy  {

  public Dummy() {
    count = 0;   // WHERE IS THIS DECLARED????????????


========= ==========
package wierd;

class Dummy1 {

  public static void sillyUselessProcThatReturnsNull() {
   "HELLO".equalsIgnoreCase( "GOODBYE" );

Question by:stockblocks
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 92

Accepted Solution

objects earned 500 total points
ID: 16908588
shouldn't compile, maybe a bug in JB.
have you tries compiling from command line with javac?

Author Comment

ID: 16908650
Never used javac, but tried your suggestion.  In MS-DOS panel, I went into the folder containing the 3 java files and issued this command:


Sure enough, it picked up on the line showing "count = 0"  (error msg was "cannot resolve symbol").

It also couldn't resolve the reference to Dummy1 in the next line, since javac doesn't know about other files in the "package".  So on a side note, how would I compile the entire package with javac?  Sorry if this is a silly question.  Does it entail use of a "make-like" file?  I've seen how JBuilder 3 creates a 'dependency' file... is that what javac uses to compile all servlets contained in a package?

LVL 92

Expert Comment

ID: 16908664
you need to add your projects directory to your classpath, eg.

javac -classpath C:\JBuilder3\myprojects

some good background on classpaths:

Author Comment

ID: 16908741
Got it.  Thanks.   So now the only error is the unresolved symbol reference to "count", as is expected!

But I'm really disappointed that JBuilder3 didn't find it.  Might assigning a different JDK fix it?  I.e., could this be due to a problem with the JDK I'm using?  Doubtful perhaps...  but I've gone so many years really thinking that JBuilder was "perfect", so I'd hate think it's a compiler bug.

Oh well.  You were extremely fast in assisting me.  I'll accept that as the definitive answer.


LVL 92

Expert Comment

ID: 16908770
doubt its a problem with the jdk, more likely a problem with JB itself

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 242
String array comparison 4 46
How  can  i  resolve  HTTP Status 404 -? 8 61
Is there a simpler dropbox system? 10 44
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question