Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > strange netbeans glitch not finding java classes

Reply
Thread Tools

strange netbeans glitch not finding java classes

 
 
gwlucas@sonalysts.com
Guest
Posts: n/a
 
      06-10-2008

I've just had something strange happen to me in Netbeans 6.1.

I was editing a file when, all of the sudden, Netbeans became unable
to find things like java.awt.event.MouseEvent and java.lang.Runnable.
I have never seen anything like this before. Does anyone have
experience with that kind of thing? Any suggestions?

My guess is that somekind of behind-the-scenes updater or something
ran and broke something (why anyone thinks that behind-the-scenes
processes that modify your computer environment are a good idea is
beyond me). I've re-installed Java and am in the process of re-
installing Netbeans. Anything I should look for?

Gary

 
Reply With Quote
 
 
 
 
gwlucas@sonalysts.com
Guest
Posts: n/a
 
      06-11-2008

Okay, I found the source of the problem and it's almost a little
funny...

While I was working, I was creating a new class file when somebody
came in to the office and interrupted. I attmpted to bail out of the
creation wizard, but being a little distracted, somehow managed to
create a file called "java.java"

This turned out to be toxic to Netbeans and the Java compiler. When I
used Netbeans to edit or compile a file which included a reference to
one of the Java API classes, such as java.lang.Runtime, it decided
that I wanted it to find the reference inside the class named
java.java. While clearly inappropriate, that was the correct behavior
based on the rules for resolving classpath and reference. So chalk it
up to operator error.

This is one of the stranger problems I've seen in a long time.

I suppose that I would have found it sooner if I had paid more
attention to the compiler warnings. I just assumed that Netbeans was
being flakey... Sometimes when you are debugging, it will get into a
confused state and the only way to correct the problem is to terminate
and restart the IDE... so having gotten used to the idea that the
program would misbehave, I wrongly assumed it was misbehaving again.
The real problem was, of course, that it was doing exactly what it was
supposed to do.

Gary



On Jun 10, 3:07*pm, (E-Mail Removed) wrote:
> I've just had something strange happen to me in Netbeans 6.1.
>
> I was editing a file when, all of the sudden, Netbeans became unable
> to find things like *java.awt.event.MouseEvent and java.lang.Runnable.
> I have never seen anything like this before. Does anyone have
> experience with that kind of thing? Any suggestions?
>
> My guess is that somekind of behind-the-scenes updater or something
> ran and broke something (why anyone thinks that behind-the-scenes
> processes that modify your computer environment are a good idea is
> beyond me). I've re-installed Java and am in the process of re-
> installing Netbeans. *Anything I should look for?
>
> Gary


 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      06-11-2008
Here is some code I use to select a "random" quotation to put an a web
page. It changes every 4 hours.

/**
* 86,400,000 the number of milliseconds in 24 hour day. Easily
fits into an int.
* We change the quotations every 4 hours, UTC.
*/
private static final int CHANGE_INTERVAL_IN_MILLIS = 4 * 60 * 60 *
1000;



final Adler32 digester = new Adler32();
int seed = ( int ) ( System.currentTimeMillis() /
CHANGE_INTERVAL_IN_MILLIS );
/// digester.update(int) not clearly documented, probably
wants ubyte.
digester.update( ( byte ) ( seed & 0xff ) );
digester.update( ( byte ) ( ( seed >>> 8 ) & 0xff ) );
digester.update( ( byte ) ( ( seed >>> 16 ) & 0xff ) );
digester.update( ( byte ) ( ( seed >>> 24 ) & 0xff ) );
digester.update( fileBeingProcessed.getPath().getBytes(
"UTF-8" ) );

// get rid of high sign bit, and low bit, which seem to be
1 disproportionately.
final int digest = (( ( int ) digester.getValue() ) << 1)
>>> 2;

final String[] candidates = category.getQuotations();

final String chosenQuote = candidates[ digest %
candidates.length ];

However it often SEEMS to sometimes pick the same quote for two
different pages, more often than I would intutitively think it would.

Further it SEEMS to favour certain quotes in the collection. I wonder
if this just my imagination, or there is some flaw in the algorithm.

--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
John B. Matthews
Guest
Posts: n/a
 
      06-11-2008
In article <(E-Mail Removed)>,
Roedy Green <(E-Mail Removed)> wrote:

> Here is some code I use to select a "random" quotation to put an a web
> page. It changes every 4 hours.
>
> /**
> * 86,400,000 the number of milliseconds in 24 hour day. Easily
> fits into an int.
> * We change the quotations every 4 hours, UTC.
> */
> private static final int CHANGE_INTERVAL_IN_MILLIS = 4 * 60 * 60 *
> 1000;
>
>
>
> final Adler32 digester = new Adler32();
> int seed = ( int ) ( System.currentTimeMillis() /
> CHANGE_INTERVAL_IN_MILLIS );
> /// digester.update(int) not clearly documented, probably
> wants ubyte.
> digester.update( ( byte ) ( seed & 0xff ) );
> digester.update( ( byte ) ( ( seed >>> 8 ) & 0xff ) );
> digester.update( ( byte ) ( ( seed >>> 16 ) & 0xff ) );
> digester.update( ( byte ) ( ( seed >>> 24 ) & 0xff ) );
> digester.update( fileBeingProcessed.getPath().getBytes(
> "UTF-8" ) );
>
> // get rid of high sign bit, and low bit, which seem to be
> 1 disproportionately.
> final int digest = (( ( int ) digester.getValue() ) << 1)
> >>> 2;

> final String[] candidates = category.getQuotations();
>
> final String chosenQuote = candidates[ digest %
> candidates.length ];
>
> However it often SEEMS to sometimes pick the same quote for two
> different pages, more often than I would intutitively think it would.
>
> Further it SEEMS to favour certain quotes in the collection. I wonder
> if this just my imagination, or there is some flaw in the algorithm.


Are you trying to make the sequence of quotes depend on the last
processed file? Maybe something like this:

// initially
Random random = new Random();
Adler32 digester = new Adler32();
...
// each new file
digester.update(fileBeingProcessed.getPath().getBy tes("UTF-8"));
...
// every n hours
random.setSeed(digester.getValue());
chosenQuote = candidates[random.nextInt(candidates.length)];

John
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
 
Reply With Quote
 
Tom Anderson
Guest
Posts: n/a
 
      06-11-2008
On Wed, 11 Jun 2008, Roedy Green wrote:

> Here is some code I use to select a "random" quotation to put an a web
> page. It changes every 4 hours.
>
> /**
> * 86,400,000 the number of milliseconds in 24 hour day. Easily
> fits into an int.
> * We change the quotations every 4 hours, UTC.
> */
> private static final int CHANGE_INTERVAL_IN_MILLIS = 4 * 60 * 60 *
> 1000;
>
> final Adler32 digester = new Adler32();
> int seed = ( int ) ( System.currentTimeMillis() /
> CHANGE_INTERVAL_IN_MILLIS );
> /// digester.update(int) not clearly documented, probably
> wants ubyte.
> digester.update( ( byte ) ( seed & 0xff ) );
> digester.update( ( byte ) ( ( seed >>> 8 ) & 0xff ) );
> digester.update( ( byte ) ( ( seed >>> 16 ) & 0xff ) );
> digester.update( ( byte ) ( ( seed >>> 24 ) & 0xff ) );
> digester.update( fileBeingProcessed.getPath().getBytes(
> "UTF-8" ) );
>
> // get rid of high sign bit, and low bit, which seem to be
> 1 disproportionately.
> final int digest = (( ( int ) digester.getValue() ) << 1)
>>>> 2;

> final String[] candidates = category.getQuotations();
>
> final String chosenQuote = candidates[ digest %
> candidates.length ];


Why are you doing all this? Why not just new Random(), generate and throw
away a few ints, and then pick one out and use it?

> However it often SEEMS to sometimes pick the same quote for two
> different pages, more often than I would intutitively think it would.
>
> Further it SEEMS to favour certain quotes in the collection. I wonder
> if this just my imagination, or there is some flaw in the algorithm.


I also have a random quote selector, and i also notice this. There are
even times when i think it's picking quotes specifically tailored for the
email i'm about to write. I think it's an illusion - if you randomly pick
quotes, you don't expect them all to appear at the same frequency, but for
some to, by chance, come up more often. Isn't it a binomial distribution
or something? Anyway, it's exactly the kind of thing that the human brain
interprets as a pattern.

tom

--
Hesgadin. It was in two parts - both of them silent. I remember this map
came with a letter accusing me of stealing eggs. I had never understood
the relationship of the map to the accusation. I still don't, but I'm
grateful for the map.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Netbeans 6.1 focus-switch glitch zerg Java 4 07-31-2008 02:08 PM
Eclipse vs. Netbeans. Netbeans is winning me over almost at first glance. Thomas G. Marshall Java 2 10-16-2006 02:54 AM
Strange scrolling glitch with Firefox History Fan Firefox 7 02-22-2006 08:52 PM
[NETBEANS] [EVALUATION] - E12 - The NetBeans Open Source Lie Ilias Lazaridis Java 0 12-12-2004 02:41 PM
Building a GUI using NetBeans platform (not Netbeans IDE !) Pimousse Java 2 04-21-2004 07:22 AM



Advertisments