comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* J2ME or Symbian applications, which is the trend? - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fa8dec74fb55dfc6
* Symbian or J2ME, which one is the trend? - 3 messages, 3 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/727a56c9759c61bb
* JTable in Applet doesn't receive keypresses under Win2000 (XP is Ok) - 2 
messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/eda43654e347cc2e
* help on threads/monitor needed - 5 messages, 3 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cefb56e3aa05046e
* field name for jOptionPane when using Eclipse? - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ecc8b53a68d74225
* compressing or encrypting a String - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d28e472c042b2e3a
* Help: JMX monitors lead to java.lang.OutOfMemoryError because of many threads 
- 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a684e98751f7c1dd
* Jasper Report and show *.txt - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/be0f6185fae2a4ee
* JNI and storing C pointers in the Java Class variables - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3948fccf951482eb
* jdbc question - 5 messages, 4 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bab6d8d5c6089b91
* EclipseTracker: Eclipse News Aggregator - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b6d3022423ff4f33
* Need a faster MouseWheel - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/672cc21925a15922

==============================================================================
TOPIC: J2ME or Symbian applications, which is the trend?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fa8dec74fb55dfc6
==============================================================================

== 1 of 2 ==
Date: Thurs, Dec 30 2004 12:08 am
From: "ChenLin"  

hi,

For mobile software development, J2ME is more portable and widely
supported; Symbian, with the largest mobile OS market share, is more
feature-rich and powerful. They each has pro's and con's.

I wander nowadays which one is the trend...are more and more people
moving to J2ME platform for development of mobile software, or there
are still a lot of people firmly sticking to Symbian native
development.

Thanks very much.




== 2 of 2 ==
Date: Thurs, Dec 30 2004 4:56 am
From: "Darryl L. Pierce"  

ChenLin wrote:
> For mobile software development, J2ME is more portable and widely
> supported; Symbian, with the largest mobile OS market share, is more
> feature-rich and powerful. They each has pro's and con's.

There are *far* fewer Symbian devices than Java-enabled mobiles. Far fewer.

-- 
Darryl L. Pierce <[EMAIL PROTECTED]>
Visit my webpage: <http://mcpierce.multiply.com>
"By doubting we come to inquiry, through inquiry truth."
     - Peter Abelard




==============================================================================
TOPIC: Symbian or J2ME, which one is the trend?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/727a56c9759c61bb
==============================================================================

== 1 of 3 ==
Date: Thurs, Dec 30 2004 12:50 am
From: [EMAIL PROTECTED] 

hi,

For mobile software development, J2ME is more portable and widely
supported; Symbian, with the largest mobile OS market share, is more
feature-rich and powerful. They each has pro's and con's.

I wander nowadays which one is the trend...are more and more people
moving to J2ME platform for development of mobile software, or there
are still a lot of people firmly sticking to Symbian native
development.

Thanks very much.




== 2 of 3 ==
Date: Thurs, Dec 30 2004 2:30 pm
From: Maxim Kasimov  

[EMAIL PROTECTED] wrote:
> hi,
> 
> For mobile software development, J2ME is more portable and widely
> supported; Symbian, with the largest mobile OS market share, is more
> feature-rich and powerful. They each has pro's and con's.
> 
> I wander nowadays which one is the trend...are more and more people
> moving to J2ME platform for development of mobile software, or there
> are still a lot of people firmly sticking to Symbian native
> development.
> 
> Thanks very much.
> 

IMHO it does not matter which platform have more features than another.
Matters only the content you can make - if for game or application implementing
quite enough features of midp1.0 you should not use Symbian native development.

-- 
Best regards,
Maxim



== 3 of 3 ==
Date: Thurs, Dec 30 2004 4:57 am
From: "Darryl L. Pierce"  

[EMAIL PROTECTED] wrote:
<snip>

Why did you repost this message in less than an hour? There's an answer 
for you in the original thread.

-- 
Darryl L. Pierce <[EMAIL PROTECTED]>
Visit my webpage: <http://mcpierce.multiply.com>
"By doubting we come to inquiry, through inquiry truth."
     - Peter Abelard




==============================================================================
TOPIC: JTable in Applet doesn't receive keypresses under Win2000 (XP is Ok)
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/eda43654e347cc2e
==============================================================================

== 1 of 2 ==
Date: Thurs, Dec 30 2004 8:56 am
From: "Dag Sunde"  

I have a (rather large as applets go) Applet
running in IE 6.0 with JRE 1.4.2 (Plugin)

Under Win XP, my JTable receives keypresses
(goes into, and out of edit cell mode, arrow
 keys moves from cell to cell, etc...) ie.
 everything is working normally.

But on every Win2000 box (Still IE 6.0/JRE 1.4.2)
It doesn't receive any form of keyboard activity.
No Arrow keys,no nothing...

If I doubleclick on one of the cells with my mouse,
the cell changes to The Celleditor, and the cursor
blinks for input as normal, but no response when I
try to type anything.

It is just like the Whole keyboard have been disabled
as long as the Applet have focus.

I'm not able to reproduce the problem in a smaller
SSCCE....

TIA...

-- 
Dag.





== 2 of 2 ==
Date: Thurs, Dec 30 2004 9:25 am
From: "Ann"  


"Dag Sunde" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have a (rather large as applets go) Applet
> running in IE 6.0 with JRE 1.4.2 (Plugin)
>
> Under Win XP, my JTable receives keypresses
> (goes into, and out of edit cell mode, arrow
>  keys moves from cell to cell, etc...) ie.
>  everything is working normally.
>
> But on every Win2000 box (Still IE 6.0/JRE 1.4.2)
> It doesn't receive any form of keyboard activity.
> No Arrow keys,no nothing...
>
> If I doubleclick on one of the cells with my mouse,
> the cell changes to The Celleditor, and the cursor
> blinks for input as normal, but no response when I
> try to type anything.
>
> It is just like the Whole keyboard have been disabled
> as long as the Applet have focus.
>
> I'm not able to reproduce the problem in a smaller
> SSCCE....
>
> TIA...
>
> --
> Dag.
>
>

Maybe the win2000 box is 10-15 times slower than the xp box
and you didn't wait long enough.






==============================================================================
TOPIC: help on threads/monitor needed
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cefb56e3aa05046e
==============================================================================

== 1 of 5 ==
Date: Thurs, Dec 30 2004 1:02 am
From: [EMAIL PROTECTED] 

2nd try to post this message, may be I directly answered to John C.
Bollinger when I posted yesterday, sorry.

John and ByteCoder, thank you for your answers so far.

I don't necessarely need multi threading but I get different String
messages from the RS232 and it makes it easier for decoding to
write/read in separte classes.

Here is a code snippet:
I have a main class which also makes the GUI(1). In a seperate class I
initialize the serial port(2). In a number of further classes I talk to
RS232 (3).
In the class (2) I have the attribute threadActive which should control
if a thread on the next task is started.
This program freezes after the first thread finished. I also tried to
make initializeEventListener() synchronized instead of the t1, t2...
methods in class SerialConnection. Then all threads are started but
only one gets finished.

(1)
public class MainClass extens Frame implements ActionListener,
ItemListener{

...some attributes

//constructor
public MainClass(String[] args){

... some GUI

connection = new SerialConnection(this,...);
initialize();
}//end constuctor

public void initialize(){

Thread t1 = new Thread(connection.t1());
t1.start();
Thread t2 = new Thread(connection.t2());
t2.start();

...some more threads doing communications with RS232

}//end initialize()

}//end class

(2)
public class SerialConnection implements CommPortOwnershipListener {

private MainClass mainClass;
...
public volatile boolean threadActive;
...
//constructor
public SerialConnection(MainClass mianClass,...){
...
this.mainClass = mainClass;
this.threadActive = false;
}

public synchronized T1 t1(){
while(this.threadActive){
try{
wait();
}catch(InterruptedException ex){}
}
notifyAll();
this.threadActive = true;

return t1 = new T1(this);
}
...same on t2,...

}//class

(3)
public class T1 implements SerialPortEventListener, Runnable {
...
private SerialConnection connection;
...

public T1(SerialConnection parent){

this.connection = parent;
}

public void run(){
initializeEventListener();
...
}

private void initializeEventListener(){
try {
connection.sPort.removeEventListener();
connection.sPort.addEventListener(this);
} catch (TooManyListenersException e) {...}
}

public synchronized void serialEvent(SerialPortEvent e) {

switch (e.getEventType()) {
...RS232 communication
}
connection.threadActive = false;
notifyAll();
}//end serialEvent

}//class




== 2 of 5 ==
Date: Thurs, Dec 30 2004 9:25 am
From: "Tony Morris"  

<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 2nd try to post this message, may be I directly answered to John C.
> Bollinger when I posted yesterday, sorry.
>
> John and ByteCoder, thank you for your answers so far.
>
> I don't necessarely need multi threading but I get different String
> messages from the RS232 and it makes it easier for decoding to
> write/read in separte classes.
>
> Here is a code snippet:
> I have a main class which also makes the GUI(1). In a seperate class I
> initialize the serial port(2). In a number of further classes I talk to
> RS232 (3).
> In the class (2) I have the attribute threadActive which should control
> if a thread on the next task is started.
> This program freezes after the first thread finished. I also tried to
> make initializeEventListener() synchronized instead of the t1, t2...
> methods in class SerialConnection. Then all threads are started but
> only one gets finished.
>
> (1)
> public class MainClass extens Frame implements ActionListener,
> ItemListener{
>
> ...some attributes
>
> //constructor
> public MainClass(String[] args){
>
> ... some GUI
>
> connection = new SerialConnection(this,...);
> initialize();
> }//end constuctor
>
> public void initialize(){
>
> Thread t1 = new Thread(connection.t1());
> t1.start();
> Thread t2 = new Thread(connection.t2());
> t2.start();
>
> ...some more threads doing communications with RS232
>
> }//end initialize()
>
> }//end class
>
> (2)
> public class SerialConnection implements CommPortOwnershipListener {
>
> private MainClass mainClass;
> ...
> public volatile boolean threadActive;
> ...
> //constructor
> public SerialConnection(MainClass mianClass,...){
> ...
> this.mainClass = mainClass;
> this.threadActive = false;
> }
>
> public synchronized T1 t1(){
> while(this.threadActive){
> try{
> wait();
> }catch(InterruptedException ex){}
> }
> notifyAll();
> this.threadActive = true;
>
> return t1 = new T1(this);
> }
> ...same on t2,...
>
> }//class
>
> (3)
> public class T1 implements SerialPortEventListener, Runnable {
> ...
> private SerialConnection connection;
> ...
>
> public T1(SerialConnection parent){
>
> this.connection = parent;
> }
>
> public void run(){
> initializeEventListener();
> ...
> }
>
> private void initializeEventListener(){
> try {
> connection.sPort.removeEventListener();
> connection.sPort.addEventListener(this);
> } catch (TooManyListenersException e) {...}
> }
>
> public synchronized void serialEvent(SerialPortEvent e) {
>
> switch (e.getEventType()) {
> ...RS232 communication
> }
> connection.threadActive = false;
> notifyAll();
> }//end serialEvent
>
> }//class
>

One can only speculate - your description is a little vague.
Here is what I hear often: "I don't have a multi-threaded application, just
a simple swing application."
Could this be what you mean when "I don't necessarely need multi threading
... the GUI(1)."?
Are you aware that a swing application is intrinsically multi-threaded?
If not, my guess is that your application has reached a deadlock state.
If so, my guess is that your application has reached a deadlock state.
I see it far too often to deviate from my speculation without further
information.

-- 
Tony Morris
http://xdweb.net/~dibblego/






== 3 of 5 ==
Date: Thurs, Dec 30 2004 4:04 am
From: [EMAIL PROTECTED] 

I am aware swing is multi threaded, but from the simple
consumer/producer examples I thought it must be easy to handle the
synchronized monitor for more than one thread.
I have tried to lock my threads to swing (GUI) with the invokeLater
method, which works. I could also take a task scheduler like the one
from Tony Dahlman at
http://pws.prserv.net/ad/programs/Programs.html#TaskScheduler
but is there no elegant way for my problem?
Can't I use the same lock for many threads (I make the lock parameter
volatile).
And does the synchronized work if it is not used in the same class (but
the classes are connected through the constuctor, 'calling' the other
class)?




== 4 of 5 ==
Date: Thurs, Dec 30 2004 1:10 pm
From: ByteCoder  

[EMAIL PROTECTED] wrote:
> 2nd try to post this message, may be I directly answered to John C.
> Bollinger when I posted yesterday, sorry.
> 
> John and ByteCoder, thank you for your answers so far.
> 
> I don't necessarely need multi threading but I get different String
> messages from the RS232 and it makes it easier for decoding to
> write/read in separte classes.
> 
> Here is a code snippet:
> I have a main class which also makes the GUI(1). In a seperate class I
> initialize the serial port(2). In a number of further classes I talk to
> RS232 (3).
> In the class (2) I have the attribute threadActive which should control
> if a thread on the next task is started.
> This program freezes after the first thread finished. I also tried to
> make initializeEventListener() synchronized instead of the t1, t2...
> methods in class SerialConnection. Then all threads are started but
> only one gets finished.
> 
<snip code>

I think you're making it way too difficult. If you just want to wait 
500ms before another thread can access RS232 you could modify the class 
that communicates with RS232 wait 500ms before the run is complete.
The above might be a bit vague...

You have one Swing thread (normal when you have a swing application).

You have one class that you use to communicate with RS232.
In that class you have a public synchronized method which does the 
actual 'talking' to the RS232.
This is a simple example of what I mean. If you make the swing app wait 
longer you could get a non-responding application, but it doesn't hang.

The frame: (generated in netBeans 4.0)

import javax.swing.JFrame;

public class GUIframe extends JFrame {

     private TalkToRS232 talkToRS232 = new TalkToRS232();

     public GUIframe() {
         initComponents();
     }

     private void initComponents() {
         pushButton = new javax.swing.JButton();

 
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
         pushButton.setText("Push me!");
         pushButton.addActionListener(new java.awt.event.ActionListener() {
             public void actionPerformed(java.awt.event.ActionEvent evt) {
                 pushButtonActionPerformed(evt);
             }
         });

         getContentPane().add(pushButton, java.awt.BorderLayout.CENTER);

         pack();
     }

     private void pushButtonActionPerformed(java.awt.event.ActionEvent 
evt) {
         try {
             talkToRS232.talkToRS232();
         } catch (InterruptedException ex) {
             System.out.println("Could not wait 500ms...");
         }
     }

     /**
      * @param args the command line arguments
      */
     public static void main(String args[]) {
         java.awt.EventQueue.invokeLater(new Runnable() {
             public void run() {
                 new GUIframe().setVisible(true);
             }
         });
     }

     // Variables declaration - do not modify
     private javax.swing.JButton pushButton;
     // End of variables declaration

}

The TalkToRS232 Class:

public class TalkToRS232 {

     public TalkToRS232() {
     }

     public synchronized void talkToRS232() throws InterruptedException {
         //...Do the talking.
         System.out.println("Waiting 500ms...");
         this.wait(500);
         System.out.println("Done waiting!");
     }
}

You could change the Swing frame to interrupt the TalkToRS232 class.

HTH,
-- 
-------------
- ByteCoder -           ...I see stupid people
-------------
                    Curiosity *Skilled* the cat



== 5 of 5 ==
Date: Thurs, Dec 30 2004 4:51 am
From: [EMAIL PROTECTED] 

I have not made it clear enough in my first posting, that I don't want
to wait, say 500 ms, in between tasks. My reason for using threads is
to make the application save and to do a fast initialization which does
not take, say 10 * 500 ms.

Ideally the GUI should not interfere (only interrupt, but not stop)
taking data from RS232, even if some user heavily uses it. So my vision
is to use one lock which I can use for all threads including AWT and
swing threads. Is this possible?





==============================================================================
TOPIC: field name for jOptionPane when using Eclipse?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ecc8b53a68d74225
==============================================================================

== 1 of 1 ==
Date: Thurs, Dec 30 2004 9:15 am
From: ted holden  

Chris Smith wrote:

> ted holden <[EMAIL PROTECTED]> wrote:
>> One other thing I notice and which you might want to comment on is the
>> following.  There seem to be several layout models in Java, and the only
>> one which seems to work or function at all, at least in Eclipse, is the
>> null layout.  The others seem to be intended for use by masochists.
>> Further, I seem to be able to avoid all such problems by simply using
>> swing container classes, particularly splitters, in lieue of trying to
>> fool
>> around with the various layouts.  Am I missing anything?
> 
> Yes, you absolutely are missing something.  Layout managers are there to
> solve a very important and difficult problem.  Though it's possible to
> properly solve this problem using a null LayoutManager, the chances that
> you're doing so are approximately nil.  For example:
> 
> 1. What happens when someone resizes your application window?  If you
> don't currently allow the user to resize your application window,
> wouldn't it be nice if they could?

That works without any problems, simply using swing frame and splitter
panels.  That's the first thing I checked. In an applet code tag you simply
set width and height to 100% and it works.

> 2. How certain are you that your layout will look presentable on a
> different operating system (or Swing look and feel) than the one you
> test one, where components may look completely different?

I'm assuming that the server for this app will run under linux and that
99.999% of all clients will be running windows.  Based on what I've seen,
I'd rather deal with any problems which come up than try to deal with java
layouts.  In fact I've stitched Tcl/Tk guis together by hand using the
layout system Tk provides and I don't remember there being any unholy level
of grief doing so.

> Layout managers, in short, are critical to writing a well-designed GUI
> application in Java.  They are also not much harder to use than
> explicitly specifying a position and size for each component; you just
> have to work at a higher level.  Some of the most important are
> BorderLayout and FlowLayout, but GridBagLayout (the infamously difficult
> layout manager) also has its uses.  Some people would prefer that I say
> BoxLayout instead of FlowLayout, but I'm not one of those people.

> As for the difficulties in using them, you haven't given enough
> information to help very much.  You mentioned that you're using a GUI
> builder with Eclipse; which one?  It may be that the GUI builder (like
> many of them do) is making layout managers more difficult than they need
> to be.

I'm using latest chapters and verses of Java and eclipse along with the
visual editor which eclipse.org provides at:

http://www.eclipse.org/vep/

This is on a fairly recent computer running Win2K, sp4 by the way.

I normally expect IDEs to come with visual gui editors included and it sort
of surprised me that Eclipse doesn't or that the user has to go out
searching for one and download same separately.

In fact I had a copy of JBuilder on the machine and had to take it off since
the JMF, which I also need for this project, does not appear to work with
JBuilder and then had to go out on a scavenger hunt.  I mean, the original
idea of Java, having a rational programming language for webcentric
applications instead of html forms and cgi applications written in perl, C,
or Tcl was easy enough to grasp, but what I see out there now in the
proliferation of both tools and technologies is almost totally bewildering. 
Basically, I consumed enough time figuring out that I wanted to use Eclipse
as opposed to other tools that I'd not have felt good about going out and
looking for the ultimate visual editor for it as opposed to the one they
provide.

Like I say, given the setup described and trying to use AWT, the layout
managers other than null simply do not appear to work or do anything
terribly useful.  In fact, I would describe the behavior of the gui tool
while trying to use AWT and the flowlayout for instance, as pathalogical. 
Widgets and/or panels which I try to place on the framework go to the
center top in minimized form and changing the "preferred size" produces
pathological results.

Like I say, the swing components work perfectly well and swing doesn't seem
to have any layout related problems.  Eclipse provides another set of
graphics called SWT which I haven't really looked into yet.










 





==============================================================================
TOPIC: compressing or encrypting a String
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d28e472c042b2e3a
==============================================================================

== 1 of 2 ==
Date: Thurs, Dec 30 2004 9:22 am
From: "Ann"  


"Tony Morris" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Wendy S" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > "David Zimmerman" <[EMAIL PROTECTED]> wrote:
> >
> > > hashcodes of strings are not neccessarily unique. Do you mind
> collisions?
> >
> > How often do two Strings compare as equal when they're actually not?  I
> > would think it's fairly rare, but in this case it wouldn't be fatal.
All
> > I'm doing is sorting images into subdirectories to make web galleries,
so
> > the worst that happens is I lose a sale if someone can't find their
> pictures
> > to place an order.
> >
> > --
> > Wendy Smoak
> >
> >
>
> It happens often.
>
> The return value of hashCode is never ever unique.
> In fact, after 2^32 + 1 invocations, a collision is guaranteed.
>
> I remember once writing a program that randomly generated 5 character
> Strings and determined if a hash code collision occurred.
> It occurred about 3 times per second on average.
>
> Take a look at how Apache Ant does it with the <tempfile> core task.
>
> I'd guess it's something along the lines of:
> while(file.exists())
> {
>     file = new File(generateNewName());
> }
>


Another problem with this is the mapping is not unique. Given a long
input String, the OP wants the same output String every time.


> Of course, this has a potential concurrency issue if file.exists() is true
> after the loop exits due to some operating system activity, and should be
> documented as such.
>
> --
> Tony Morris
> http://xdweb.net/~dibblego/
>
>
>





== 2 of 2 ==
Date: Thurs, Dec 30 2004 11:51 am
From: "Chris Uppal"  

Wendy S wrote:

> How often do two Strings compare as equal when they're actually not?

[I'm assuming you mean, "how often to they have equal hashes when they're not
equal?"]

If you are producing 32-bit hash codes, and if your hashing algorithms produces
more-or-less random values, then you'd expect to find at least 1 pair of
strings with the same hash if you have at least 2^16 input strings.  65,000
files isn't really /that/ many, so I wouldn't recommend using a 32-bit hash for
this kind of purpose unless you know that your application is going to be
handling a lot less than 65K files.

Also that is on the assumption that String.hash() is of reasonable quality.  It
doesn't look spectacularly good to me (though I haven't attempted to validate
it).  In any case, if you want your hashes to be reliable over a release of a
new JVM implementation, then you can't base your file names on the
String.hash() function since it is possible that the next version of the JVM
will use a different hash method (it has already changed once, so maybe it'll
change again).

I think you'd be better off using a hash function that:

    a) produces a lot more than 32 bits of output

    b) is defined independently of the JVM implementation.

One excellent source of such hashes is to use a crypto hash like SHA-1 (160
bit?) or MD5 (128 bit).  I've never had to do that in Java, but I presume one
would start with an instance of MessageDigest.

However the actual crypto-graphic quality is unimportant here, so you might
find it easier and quicker to code your own 64-bit (say) hash function.  Here's
what I would try first if I needed to do this, it's translated directly from
'C' so it'll probably not compile...

    /**
      * a String hash implemented as a perturbed 64-bit linear congruential
pseudo-random
      * number generator.
      */
    long
    longLinearCongruentialHash(String input)
    {
        long hash = 0L;
        for (int i = 0; i < input.length(); i++)
        {
            hash += input.charAt(i);
            hash *= 6364136223846793005L;
        }

        return hash;
    }

    -- chris






==============================================================================
TOPIC: Help: JMX monitors lead to java.lang.OutOfMemoryError because of many 
threads
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a684e98751f7c1dd
==============================================================================

== 1 of 1 ==
Date: Thurs, Dec 30 2004 1:24 am
From: [EMAIL PROTECTED] (Andre Ranvik) 

I need to monitor approximately 100000 nodes in a system, where each
has around 50 fields that are required to be monitored (total of 50 *
100000 fields). The granularity period (time between checking each
field) needs to be no greater than 2 seconds.
JMX has been proposed to be used, but it seems like it is not capable
of monitoring as many fields.

What I have tried is to use both J2SE5 and MX4J. J2SE5 starts up a new
thread for each monitor, and runds quickly out of memory.  I have
tried to set the -Xss startup option, but with only minor improvement.
MX4J uses a fixed number of threads, but it slows down to a crawl when
going beyond 10000 fields.

A solution seems to use a thread pool, where a fixed set of threads
would monitor X number of fields each, but this would require me to
write my own monitor MBeans, something that I want to avoid. The
monitor I am using is the GaugeMonitor for all fields.

Does anybody have a better approach for how to monitor these fields?


Thanks,
Andre Ranvik




==============================================================================
TOPIC: Jasper Report and show *.txt
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/be0f6185fae2a4ee
==============================================================================

== 1 of 1 ==
Date: Thurs, Dec 30 2004 10:28 am
From: "cc"  

Hi,
how show a simple file *.txt from Jasper Report ?

Thanks,
CC 






==============================================================================
TOPIC: JNI and storing C pointers in the Java Class variables
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3948fccf951482eb
==============================================================================

== 1 of 1 ==
Date: Thurs, Dec 30 2004 11:28 am
From: Gordon Beaton  

On 29 Dec 2004 00:46:18 -0800, [EMAIL PROTECTED] wrote:
> Long does not work, but I need to double-check my code.

It always has for me.

> One question :
> will pointer-as-long be also OK on a 64bits machines ?
> ( I do not have an Itanium, but AMD does have fine 64bits CPU... )

I can't see why not. Java long is 64 bit signed, but since you
shouldn't be manipulating the value in Java anyway, the sign shouldn't
make any difference for storing 64 bit pointer values.

/gordon

-- 
[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e




==============================================================================
TOPIC: jdbc question
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bab6d8d5c6089b91
==============================================================================

== 1 of 5 ==
Date: Thurs, Dec 30 2004 10:11 am
From: "Chris Uppal"  

Mark Thornton wrote:

> By contrast the query to find if the row
> exists can be written to work unchanged on most databases, although as
> you point out it is likely to be slower.

Or, more accuately, /not/ work on most databases ;-)  It leaves a hole where
another app could insert the to-be-duplicate row into the DB between your query
and your insert.

Before this thread, I hadn't realised just how badly broken the JDBC stuff
is -- insert-and-catch-error is a natural technique, but it seems to be more
than a little tricky to code it up in JDBC.  Virgil's suggestion of storing the
driver-specific (but it /shouldn't/ be !) SQLState (or DB error code) looks
like the least bad option here.

    -- chris





== 2 of 5 ==
Date: Thurs, Dec 30 2004 10:15 am
From: "Chris Uppal"  

Ann wrote:

> > Using JDBC , what would be a more elegant way of determining  whether or
> > not a record already exists in a DB table  before inserting it?

> Why do you want to know?

When I've been in this position, it's because I needed to ensure that a row
with <such-and-such> values existed in the table.  I'd insert it if one doesn't
already exist, or update an existing row if there is one.

    -- chris





== 3 of 5 ==
Date: Thurs, Dec 30 2004 12:13 pm
From: Mark Thornton  

Chris Uppal wrote:
> Mark Thornton wrote:
> 
> 
>>By contrast the query to find if the row
>>exists can be written to work unchanged on most databases, although as
>>you point out it is likely to be slower.
> 
> 
> Or, more accuately, /not/ work on most databases ;-)  It leaves a hole where
> another app could insert the to-be-duplicate row into the DB between your 
> query
> and your insert.

Not true --- it will work wherever transactions are properly supported. 
You simply have to turn off the auto commit and commit the transaction 
yourself after doing the update(s). Admittedly you may still have to 
watch for serialization exceptions (deadlock), but that should be rare.

Nor is this really a flaw in JDBC but rather reflects the unsatisfactory 
state of SQL and database standardisation generally.

Mark Thornton



== 4 of 5 ==
Date: Thurs, Dec 30 2004 1:47 pm
From: anonymous  

jmt wrote:
> Using JDBC , what would be a more elegant way of determining  whether or 
> not a record already exists in a DB table  before inserting it?
> 
> Jeff
> Registered Linux user number 366042

If you want to insert the record if possible (ie the record does not 
exist already) I'd assume a solid data model with referential integrety 
and primary keys.

Just insert the thing and catch the exception. The exception or the 
sqlstate/sqlcode should tell you what went wrong and your code can act 
appropriately.

You will have to wrap your sql code in try/catch anyway.

If you want to try and bypass the exception handling stuff, you'd have 
to first do a select or a select into then examine the result.



== 5 of 5 ==
Date: Thurs, Dec 30 2004 1:47 pm
From: Thomas Kellerer  

Chris Uppal wrote on 30.12.2004 11:15:
> Ann wrote:
> 
> 
>>>Using JDBC , what would be a more elegant way of determining  whether or
>>>not a record already exists in a DB table  before inserting it?
> 
> 
>>Why do you want to know?
> 
> 
> When I've been in this position, it's because I needed to ensure that a row
> with <such-and-such> values existed in the table.  I'd insert it if one 
> doesn't
> already exist, or update an existing row if there is one.


Why not do it the other way round? Update the row first, then check the 
number of affected rows (which is returned by the executeUpdate() method 
and is DBMS indepdent). If zero records were affected then the record is 
not there and you can insert it. Thus you do not need to rely on error 
codes for specific DBMS when catching an error during the insert.

Thomas




==============================================================================
TOPIC: EclipseTracker: Eclipse News Aggregator
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b6d3022423ff4f33
==============================================================================

== 1 of 1 ==
Date: Thurs, Dec 30 2004 3:58 am
From: [EMAIL PROTECTED] 

http://eclipsetracker.blogspot.com/

Hello,

I wanted to contribute to the success of Eclipse in my
own small way. I started maintaining a blog that is
essentially a news aggregator with almost daily updates
on Eclipse news stories.

I would like to share the blog URL with rest of the
community.
http://eclipsetracker.blogspot.com/

Thanks!





==============================================================================
TOPIC: Need a faster MouseWheel
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/672cc21925a15922
==============================================================================

== 1 of 1 ==
Date: Thurs, Dec 30 2004 12:15 pm
From: Daniel Tryba  

Ramon <[EMAIL PROTECTED]> wrote:
> I just got a nice class called JadeDisplay which has
> saved me a lot of programming.  However, I think the
> JD programmers misinterpreted the concept of "line":
> when the user is scrolling a graphics file (TIFF, GIF,
> JPEG) the wheel scrolling is painfully slow.

No solution to your actual question (which doesn't seem to be adjustable
programmatically from within Java (see the scrolltype unit vs. block:
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/event/MouseWheelEvent.html#getScrollType())),
but I personally would also use the getClickCount from the
MouseWheelEvent. If the user scrolls slowly there will be a "line by
line", faster scrolling will increment the numbers of "lines" scrolled.




==============================================================================

You received this message because you are subscribed to the Google
Groups "comp.lang.java.programmer" group.

To post to this group, send email to [EMAIL PROTECTED] or
visit http://groups-beta.google.com/group/comp.lang.java.programmer

To unsubscribe from this group, send email to
[EMAIL PROTECTED]

To change the way you get mail from this group, visit:
http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

To report abuse, send email explaining the problem to [EMAIL PROTECTED]

==============================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to