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

Today's topics:

* Tool for sharing C data-structures with Java - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bf1b9c3fa7ec6f0b
* Need as much help as possible - 3 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c8e64b34d7154d8
* Custom paint in JScrollPane - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ee45b5808b7ee9ef
* writing clobs using oracle thin driver - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f9dc55b5f77991a1
* Question about passing values? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8fe1c15e0fc2a949
* Swing - Detect how focus was moved? - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/844c965c9aa3c8c1
* Repainting a image in java - 5 messages, 5 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/218e95a0a0ff772
* Creating primitive data types from contents of String - 4 messages, 4 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4d8fc307a0b9125d
* Blogging Java - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/360cc2330132c81d
* Java Question - 4 messages, 4 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bf3236c98b871078
* Tomcat - DataSource Exception - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7adac2daa2a6844f
* Full Screen Game - 4 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/512b4296a1e5c69f
* Help needed! how to deploy java application - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1be98d1355247063
* java 1.5.0 - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b71406a950424de0
* How do you cast to array? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/884dee2def4bbb47
* Memory sensitive caches - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/847960ed2b3fe4f4
  
==========================================================================
TOPIC: Tool for sharing C data-structures with Java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bf1b9c3fa7ec6f0b
==========================================================================

== 1 of 1 ==
Date:   Sat,   Nov 13 2004 2:05 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

Michael Borgwardt wrote:

> > I'm thinking about making a program in java that will allow you to use
> > C data-structures (probably read from a network) easily:
>
> C structs are not portable, because data type lenghts, endianness and
> especially alignments differ between platforms and compilers.

That just means that you'd need some way of parameterising the code with
settings reflecting the known behaviour of some specific compiler(s).
Perfectly doable, and even sensible.

I agree that you don't want to get into a position where you are dependent on
the unspecified behaviour of a C compiler in the first place.  But if you /are/
in that position then centralising and encapsulating the required knowledge in
(the configuration of) some tool or library seems like a Good Idea to me.

    -- chris






==========================================================================
TOPIC: Need as much help as possible
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c8e64b34d7154d8
==========================================================================

== 1 of 3 ==
Date:   Sat,   Nov 13 2004 2:09 am
From: steve <[EMAIL PROTECTED]> 

On Fri, 12 Nov 2004 03:04:49 +0800, WCU_Student3456 wrote
(in article 
<[EMAIL PROTECTED]>):

> hey i'm new to the java scene and i have a major assignment due for class
> on the 12th of nov.  I need help with a program that has a point class...a
> driver and a circle class. the program is suppost to display info about the
> circle...if anyone is interested or has pitty...college students love
> pitty..please respond and i will try to send the assignment to you...i
> have it scanned on adobe...
> 
> thanks ever so much
> 

I love you  students.

How the hell  you guys think you  are going to survive in the real world, is 
a complete mistery to me.

However if you promise the following:

1. To go work at mac Donald's  for the rest of your life.
2. Never to turn a computer on , other than  for looking at porn or playing 
computer games.
3. Send me the email address of your tutor.

Then i think we can work something out.

Steve




== 2 of 3 ==
Date:   Sat,   Nov 13 2004 8:00 am
From: "Thomas G. Marshall" <[EMAIL PROTECTED]> 

Virgil Green coughed up:
> "Thomas G. Marshall"
> <[EMAIL PROTECTED]> wrote in
> message news:[EMAIL PROTECTED]
>> Rob coughed up:
>>> dar7yl wrote:
>>> I'll do it for a bottle of vodka.
>>> That, or $25 CDN.
>>
>> Vodka?  Real engineers are powered by Diet Coke.
>>
>> By the freaking gallon....
>
> "Diet"?
>
> Yech.... only full strength (and original) for me.
>
>  - Virgil

Diet /is/ full strength.  Adding sugar only causes your body to react by
flooding your system with enough insulin to transfer the sugar through the
cell boundaries alright, but will also hang around long enough in your
system to risk putting you to sleep.  Or at least largely negate the affect
of the caffeine.

-- 
"Gentlemen, you can't fight in here! This is the War Room!"





== 3 of 3 ==
Date:   Sat,   Nov 13 2004 8:03 am
From: "Thomas G. Marshall" <[EMAIL PROTECTED]> 

steve coughed up:
> On Fri, 12 Nov 2004 03:04:49 +0800, WCU_Student3456 wrote
> (in article
> <[EMAIL PROTECTED]>):
>
>> hey i'm new to the java scene and i have a major assignment due for
>> class on the 12th of nov.  I need help with a program that has a
>> point class...a driver and a circle class. the program is suppost to
>> display info about the circle...if anyone is interested or has
>> pitty...college students love pitty..please respond and i will try
>> to send the assignment to you...i have it scanned on adobe...
>>
>> thanks ever so much
>>
>
> I love you  students.
>
> How the hell  you guys think you  are going to survive in the real
> world, is a complete mistery to me.
>
> However if you promise the following:
>
> 1. To go work at mac Donald's  for the rest of your life.
> 2. Never to turn a computer on , other than  for looking at porn or
> playing computer games.
> 3. Send me the email address of your tutor.
>
> Then i think we can work something out.
>
> Steve


Back when Things Were Rotten....

I cannot imagine how I managed to get so many things done before the
internet.  Everything I ever was contracted to do had [maybe] a single
right-up in a technical journal somewhere deep in the bowels of the MIT
library (I didn't go to mit, but drove the hour into Cambridge more than
once to use it).  Oi.

And all the CS students clamoring to take a peak at the few knuth's that
existed in my university.  No university ever bought enough of those things
for their libraries.








-- 
"Gentlemen, you can't fight in here! This is the War Room!"






==========================================================================
TOPIC: Custom paint in JScrollPane
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ee45b5808b7ee9ef
==========================================================================

== 1 of 2 ==
Date:   Sat,   Nov 13 2004 2:40 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

Thomas Richter wrote:

> Well, JScrollPane.add(myclass). I suppose this is incorrect then and I
> should rather build another JPanel, add the class to this JPanel and then
> put the JPanel into the JScrollPane on construction as you did?

If you want to "add" the subview later, then you should use
JScrollPane.setViewportView() not add().  (Because a JScrollPane is just
assemblage of a few scrollbar components and a Viewport component, plus some
glue to tie them together, and it's really the Viewport that needs to "contain"
the thing you're adding, not the JScrollPane itself).  The documentation for
JScrollPane isn't a masterpiece of clarity, but if you read it a few times then
it should make more sense.

    -- chris





== 2 of 2 ==
Date:   Sat,   Nov 13 2004 3:50 am
From: Babu Kalakrishnan <[EMAIL PROTECTED]> 

Thomas Richter wrote:
> 
>>What happens if source.getImage() gets called repeatedly ? Does it
>>try to recreate the image everytime or does it return a cached copy ?
> 
> 
> No, it returns a cached copy. Recreating the image could be rather
> wasteful. It is not very huge in the demo code, but it could become
> quite large.
> 

I asked because trying to recreate it can lead to problems in painting.

> 
> I hope this is maybe not related, but could you please explain me what's
> this image observer is good for in first place? (Ehem...)
> 

I think it isn't related at all. Your problem is most likely what Chris 
(Uppal) pointed out. "add"ing to the JScrollPane is incorrect. You need 
to set the client panel as the "view" of its Viewport.

Look at the API documentation of the java.awt.image.ImageObserver 
interface and that of the drawImage method of the Graphics class for 
details on qhat an imageObserver is used for. The java.awt.Component 
class implementats this interface, and all that the implementation does 
is to trigger a repaint() on itself as more pixels arrive (in its 
imageUpdate method).

BK




==========================================================================
TOPIC: writing clobs using oracle thin driver
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f9dc55b5f77991a1
==========================================================================

== 1 of 1 ==
Date:   Sat,   Nov 13 2004 2:18 am
From: steve <[EMAIL PROTECTED]> 

On Thu, 11 Nov 2004 20:16:37 +0800, Cookie Monster wrote
(in article <[EMAIL PROTECTED]>):

> Hi,
> 
> I have a problem with the oracle thin driver writing clobs greater then 4000
> chars.  Basically using the oci driver the following java code works fine:
> 
> PreparedStatement statement;
>   Reader bodyReader = null;
>   try {
>    bodyReader = new StringReader(parameter.toString());
>    statement.setCharacterStream(1,bodyReader,parameter.toString().length());
>   } catch (Exception e) {
>    e.printStackTrace();
>    throw new SQLException("Failed to set text field.");
>   }
> 
> But when using with the thin driver nothing gettings written to the clob.
> Does anyone know a solution to this problem where I can use the thin driver
> for writing clobs??
> 
> Thanks,
> Steve.
> 
> 


don't be lazy.
1.go look at the ask tom, section on the oracle website.
2. download the sample code from oracle website.
both are free.





==========================================================================
TOPIC: Question about passing values?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8fe1c15e0fc2a949
==========================================================================

== 1 of 1 ==
Date:   Sat,   Nov 13 2004 2:55 am
From: Joona I Palaste <[EMAIL PROTECTED]> 

Ken Adams <[EMAIL PROTECTED]> scribbled the following:
> Ok, this might be a bit of a strange question but. Is there anyway that a 
> function can get a string representation of the variable name that was 
> passed into the functions parameters. So say you have some code like

> int tester =0;

> foo(tester);

> foo(int value)
> {
>     in here, is there any way to get the string value "tester" from the 
> value reference?
> }
> Thanks
> Perhaps using objects a guy could use reflection I suppose to do this. Any 
> comments on that as well.

Suppose you called foo(3); instead. Now what would your "string value"
be?

-- 
/-- Joona Palaste ([EMAIL PROTECTED]) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"It's not survival of the fattest, it's survival of the fittest."
   - Ludvig von Drake




==========================================================================
TOPIC: Swing - Detect how focus was moved?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/844c965c9aa3c8c1
==========================================================================

== 1 of 2 ==
Date:   Sat,   Nov 13 2004 2:56 am
From: "MikL" <[EMAIL PROTECTED]> 


"Ann" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

> >
> Not sure, but can you set a flag in "mouse listener?"

Yes, I can set a flag if mousePressed() was preceded by a requestFocus()
that hasn't yet been followed by a focusGained() (and the control doesn't
yet have focus), but that involves making what I believe is an undocumented
assumption about the order of mouse vs. focus events that might change in a
different release of Swing.  It also doesn't cater for the situations in
which the requestFocus() is never followed by a focusGained(), thus leaving
"focus pending" flags set indefinitely.  It feels like a fragile design that
I'd rather avoid if I can.





== 2 of 2 ==
Date:   Sat,   Nov 13 2004 3:18 am
From: "Andrei Kouznetsov" <[EMAIL PROTECTED]> 

> Yes, I can set a flag if mousePressed() was preceded by a requestFocus()
> that hasn't yet been followed by a focusGained() (and the control doesn't
> yet have focus), but that involves making what I believe is an
undocumented
> assumption about the order of mouse vs. focus events that might change in
a
> different release of Swing.  It also doesn't cater for the situations in
> which the requestFocus() is never followed by a focusGained(), thus
leaving
> "focus pending" flags set indefinitely.  It feels like a fragile design
that
> I'd rather avoid if I can.

don't use boolean flag.
every event has a timestamp, you can compare timestamps of your
events and if differense is _very_small_ then you know it was focus change
after mouse click.

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities






==========================================================================
TOPIC: Repainting a image in java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/218e95a0a0ff772
==========================================================================

== 1 of 5 ==
Date:   Sat,   Nov 13 2004 3:20 am
From: [EMAIL PROTECTED] (Guy) 

Hello

Ive seen tons of posts on this subject, but none of them reaaly helped
me with this particular problem. Im new to JAVA graphics but not to
java itself.

I have a JFrame with two buttons and a JPanel on it. when I push a
button a quite complicated process takes place (including database
access etc.) which results in an image drawn on the JPanel.

Now this image disappears whenever I resize the main frame. I managed
to make it draw again using repaint() and running the whole process
again each time the frame resizes, like it is said on many books and
websites. But this is very slow and resource consuming.
Is there a way to just save the image (maybe the Graphics2D object ?)
and redraw it again without all the hassle of constructing it from
scratch ?

Thank you

Guy



== 2 of 5 ==
Date:   Sat,   Nov 13 2004 3:37 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 13 Nov 2004 03:20:14 -0800, Guy wrote:

> Now this image disappears whenever I resize the main frame. I managed
> to make it draw again using repaint() and running the whole process
> again each time the frame resizes, like it is said on many books and
> websites. But this is very slow and resource consuming.
> Is there a way to just save the image (maybe the Graphics2D object ?)
> and redraw it again without all the hassle of constructing it from
> scratch ?

Write it to the Graphics of a BufferedImage.
Then g.drawImage() the result.

HTH

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



== 3 of 5 ==
Date:   Sat,   Nov 13 2004 3:55 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

Guy wrote:

> But this is very slow and resource consuming.
> Is there a way to just save the image (maybe the Graphics2D object ?)
> and redraw it again without all the hassle of constructing it from
> scratch ?

Not really.  Whatever you do will amount to a variant on the same basic idea:
save the data you need to reconstruct the graphics and use that to redraw when
the size/shape of the window changes.

You can think of "saving the data you need" in several ways, which will
correspondingly flavour your design and implementation.

+  you could create an abstract graphical description (scale independent) of
the "picture".  I.e. generate a "display list" when the button is clicked, and
re-apply it to the pane whenever it changes size/aspect ratio.  (The classes
implementing java.awt.Shape may help with this approach).

+ you could think of the saved data as a mere cache, used privately just to
speed up rendering.  In this case you would save only the minimum that you need
and without regard to whether it forms a coherent body of information.

+ you could think of the data as a "model" (in the sense of MVC) which you
build from the database, and then the pane in your UI is a "view" (in the same
sense) that renders a way of displaying the model.

There may be other, or intermediate, ways of thinking about it too.  But they
all come down to the same basic architecture -- save the data you will need
later.

    -- chris





== 4 of 5 ==
Date:   Sat,   Nov 13 2004 4:03 am
From: Babu Kalakrishnan <[EMAIL PROTECTED]> 

Andrew Thompson wrote:
> On 13 Nov 2004 03:20:14 -0800, Guy wrote:
> 
> 
>>Now this image disappears whenever I resize the main frame. I managed
>>to make it draw again using repaint() and running the whole process
>>again each time the frame resizes, like it is said on many books and
>>websites. But this is very slow and resource consuming.
>>Is there a way to just save the image (maybe the Graphics2D object ?)
>>and redraw it again without all the hassle of constructing it from
>>scratch ?
> 
> 
> Write it to the Graphics of a BufferedImage.
> Then g.drawImage() the result.
> 

I think this needs a little more clarification.

The disappearance of the image on resizing the frame indicates that the 
painting of the panel is done outside its paintComponent method. In 
order for the panel to maintain the image at all times, the painting 
must be done inside this method. So the construction of the the image 
and saving it to a BufferedImage object (as Andrew suggested) can be 
done outside the paintComponent method, but the drawImage call onto the 
actual component _must_ be performed inside the paintComponent method, 
and should be done on the Graphics object passed to you as the argument 
of the method.

BK



== 5 of 5 ==
Date:   Sat,   Nov 13 2004 7:25 am
From: "Andrei Kouznetsov" <[EMAIL PROTECTED]> 

> Ive seen tons of posts on this subject, but none of them reaaly helped
> me with this particular problem. Im new to JAVA graphics but not to
> java itself.
>
> I have a JFrame with two buttons and a JPanel on it. when I push a
> button a quite complicated process takes place (including database
> access etc.) which results in an image drawn on the JPanel.
>
> Now this image disappears whenever I resize the main frame. I managed
> to make it draw again using repaint() and running the whole process
> again each time the frame resizes, like it is said on many books and
> websites. But this is very slow and resource consuming.
> Is there a way to just save the image (maybe the Graphics2D object ?)
> and redraw it again without all the hassle of constructing it from
> scratch ?

you need something like ImagePanel:

class ImagePanel extends JPanel {

    Image image;

    public void setImage(Image image) {
        this.image = image;
    }

    public void paintComponent(Graphics g) {
        if(image != null) {
            g.drawImage(image, 0, 0, this);
        }
    }

    public Dimension getPreferredSize() {
        int w, h;
        if(image == null) {
            return new Dimension(0, 0);
        }
        w = image.getWidth(null);
        h = image.getrHeight(null);
        return new Dimension(w > 0 ? w : 0, h > 0 ? h : 0);
    }
}

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities


"Guy" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> Hello
>
>
> Thank you
>
> Guy






==========================================================================
TOPIC: Creating primitive data types from contents of String
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4d8fc307a0b9125d
==========================================================================

== 1 of 4 ==
Date:   Sat,   Nov 13 2004 3:47 am
From: [EMAIL PROTECTED] (Jesper Sahner) 

Hi!

Let's say that s is a String containing a name. How do I then
(dynamically) create an integer with that specific name like:

String s="abc";
int abc;

String s="def";
int def;

...

E.g. the String-names could be some names read from a file.

Regards,
Jesper



== 2 of 4 ==
Date:   Sat,   Nov 13 2004 4:07 am
From: Joona I Palaste <[EMAIL PROTECTED]> 

Jesper Sahner <[EMAIL PROTECTED]> scribbled the following:
> Hi!

> Let's say that s is a String containing a name. How do I then
> (dynamically) create an integer with that specific name like:

> String s="abc";
> int abc;

> String s="def";
> int def;

> ...

> E.g. the String-names could be some names read from a file.

You can't. Variable names, at least local ones (method scope) are an
entirely compile-time concept and can't be manipulated at run-time.
What are you really trying to accomplish with this?

-- 
/-- Joona Palaste ([EMAIL PROTECTED]) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"It's time, it's time, it's time to dump the slime!"
   - Dr. Dante



== 3 of 4 ==
Date:   Sat,   Nov 13 2004 4:33 am
From: Oscar kind <[EMAIL PROTECTED]> 

Jesper Sahner <[EMAIL PROTECTED]> wrote:
> Let's say that s is a String containing a name. How do I then
> (dynamically) create an integer with that specific name like:
> 
> String s="abc";
> int abc;

You don't. After all: how would you reference it?

If you need to create labels for numbers/objects/... dynamically, use a
Map. Also note that you cannot use primitive types like int, char,
boolean, etc. Use Integer, Crahacer, Boolean, etc. instead.


-- 
Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website

PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2



== 4 of 4 ==
Date:   Sat,   Nov 13 2004 7:36 am
From: "Alberto" <[EMAIL PROTECTED]> 

I'm not sure why would you like to do that. However, if you are trying
to dynamically create an object depending on input entered, you may
want to read about "Reflection". Keep in mind this will only work on
data objects, not on primitives.

You won't be able to create a primitive, they are not objects. You
could use wrapper classes (Objects) for those primitives (or you could
write your own). If you still insit in storing and defining a variable
from input, a good approach could be to use a data structure (create
your own object) to do the abstraction for you.





==========================================================================
TOPIC: Blogging Java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/360cc2330132c81d
==========================================================================

== 1 of 1 ==
Date:   Sat,   Nov 13 2004 5:54 am
From: Leo Wong <[EMAIL PROTECTED]> 

Using width and height:
http://leowong2004.blogspot.com/2004/11/prayer.html

Leo Wong
-- 
Mary and Leo's website: http://www.albany.net/~hello/
Leo's blog: http://leowong2004.blogspot.com/




==========================================================================
TOPIC: Java Question
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bf3236c98b871078
==========================================================================

== 1 of 4 ==
Date:   Sat,   Nov 13 2004 8:35 am
From: "scorpion53061" <[EMAIL PROTECTED]> 

My company has asked me to learn Java. My background is vb.net.

They bought me Sun Java Studio Enterprise 6 2004Q1

Please recommend a comprehensive book I can sit down and go hide for about 6 
months and get me going.

By the way, .NET had ADO.NET? Is there naything similar in java? 





== 2 of 4 ==
Date:   Sat,   Nov 13 2004 9:33 am
From: "Alberto" <[EMAIL PROTECTED]> 

Sun offers a very comprehensive tutorial on all their products. That
would include java technologies. You can read pretty much anything you
need to get you going until . I'm not familiar with ADO.NET that much,
but I understand it to be the "suite of data access technologies
included in the .NET Framework class libraries". In java you could read
the JAVA-API documentation for further info.

If you prefer to get a paper based (or even a free pdf - it's huge),
you should read "Thinking in Java" by Bruce Eckel. It's one of my
favorites...

Good luck!




== 3 of 4 ==
Date:   Sat,   Nov 13 2004 9:34 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Sat, 13 Nov 2004 10:35:56 -0600, scorpion53061 wrote:

> My company has asked me to learn Java. 

Best place for Java starters is..
<http://www.physci.org/codes/javafaq.jsp#cljh>

> They bought me Sun Java Studio Enterprise 6 2004Q1

Learn how to write Java before you become immersed in 
an IDE, it will just get in the way.
<http://www.xdweb.net/~dibblego/java/faq/answers.html#Q34>

> Please recommend a comprehensive book ..

Are you strictly after books?  There are a lot of (damn fine)
tutorials and how-to's on the net.  The Java groups here are
(possibly) the best way to clarify points that might be 
confusing you.  Then of course, there are the JavaDocs.

>..I can sit down and go hide for about 6 
> months and get me going.
> 
> By the way, .NET had ADO.NET? Is there naything similar in java?

Java has lots of acronyms, yes.   [ ;-) ]

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



== 4 of 4 ==
Date:   Sat,   Nov 13 2004 9:52 am
From: Oscar kind <[EMAIL PROTECTED]> 

scorpion53061 <[EMAIL PROTECTED]> wrote:
> My company has asked me to learn Java. My background is vb.net.
> 
> They bought me Sun Java Studio Enterprise 6 2004Q1

A quick search led me to think this is an IDE. If so, learn Java without
it (so you'll learn the compilation, classpath, package and build
details).

Once you've mastered the basics (say halfway through learning for an
equivalent of the SCJP (a basic Java certifcate by Sun), it's time to
start using it.


> Please recommend a comprehensive book I can sit down and go hide for about 6 
> months and get me going.

Have a look at http://www.javaranch.com/
They have several sections, among which:
- a forum for those who wish to get a Java certificate
  (a simple way to show your boss you've mastered Java)
- reading material for learning Java and also to prepare for the
  certification exams
- code examples, including explanations (although you may not need that
  anymore, given you're already a programmer)


-- 
Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website

PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2




==========================================================================
TOPIC: Tomcat - DataSource Exception
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7adac2daa2a6844f
==========================================================================

== 1 of 1 ==
Date:   Sat,   Nov 13 2004 8:38 am
From: [EMAIL PROTECTED] (Martin Huber) 

Hello,

i have a problem. I am using Tomcat 4.0 and MySql as database. I want
using the database connection pooling mechanism in Tomcat, but I have
problems.

If I test the connection, I get following error message:

TyrexDataSourceFactory:  Cannot create DataSource, Exception
java.lang.NoClassDefFoundError: tyrex/jdbc/xa/EnabledDataSource 
      at org.apache.naming.factory.TyrexDataSourceFactory.getObjectInstance(Ty
rexDataSourceFactory.java:163)
        at 
org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:165)
        at 
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301)
.
.
.
A problem occurred while retrieving a DataSource object
javax.naming.NamingException: Exception creating DataSource:
tyrex/jdbc/xa/EnabledDataSource


So, I have searched in different groups, but I did not found any
solution for my problem. I have enclosed my sourcecode. Maybe someone
can help me.

Thank you very much

Martin Huber

P.S. Sorry for my english...


Code in DatabaseManager.java (Servlet):
try {
                Context initCtx = new InitialContext();
                Context envCtx = (Context) initCtx.lookup("java:comp/env");
                ds = (DataSource) envCtx.lookup("jdbc/DatabaseManager");
                con = ds.getConnection();
                Statement stmt = con.createStatement();
                System.out.println("executed lookup for jdbx. JON");
        }
        catch (javax.naming.NamingException e){
                System.out.println("A problem occurred while retrieving a 
DataSource
object");
                System.out.println(e.toString());
        }



Settings in server.xml:

<Context path="/DatabaseManager"
         docBase="DatabaseManager"
         debug="1"
         reloadable="true"
         crossContext="false">

  <Resource name="jdbc/DatabaseManager"
    auth="SERVLET"
    type="javax.sql.DataSource" />

  <ResourceParams name="jdbc/DatabaseManager">


    <parameter>
          <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>

    <parameter>
      <name>driverClassName</name>
      <value>org.gjt.mm.mysql.Driver</value>
    </parameter>

    <parameter>
      <name>url</name>
      <value>jdbc:mysql:///bfdr</value>
    </parameter>

    <parameter>
      <name>username</name>
      <value></value>
    </parameter>

    <parameter>
      <name>password</name>
      <value></value>
    </parameter>

    <parameter>
      <name>maxActive</name>
      <value>20</value>
    </parameter>

    <parameter>
      <name>maxIdle</name>
      <value>10</value>
    </parameter>

    <parameter>
      <name>maxWait</name>
      <value>-1</value>
    </parameter>

    <parameter>
      <name>testOnBorrow</name>
      <value>true</value>
    </parameter>

    <parameter>
      <name>testOnIdle</name>
      <value>true</value>
    </parameter>

    <parameter>
      <name>validationQuery</name>
      <value>select current_date</value>
    </parameter>

  </ResourceParams>
</Context>




Settings in web.xml:

<resource-ref>
   <description>
                BFD-Regensburg
   </description>
   <res-ref-name>
     jdbc/DatabaseManager
   </res-ref-name>
   <res-type>
     javax.sql.DataSource
   </res-type>
   <res-auth>
     SERVLET
   </res-auth>
 </resource-ref>




==========================================================================
TOPIC: Full Screen Game
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/512b4296a1e5c69f
==========================================================================

== 1 of 4 ==
Date:   Sat,   Nov 13 2004 9:13 am
From: "Mike" <[EMAIL PROTECTED]> 

Sup everyone,
I'm still only a scenior in highshool, but I am attempting to make
a full screen version of the board game Triopoly (Monoply with 3 levels
and a heck of a lot more money going around the table).  I am currently
in AP Java AB (AP Java 2) and have set up most of the needed classes,
and am beginning to debug it in dos.  I know how to set up everything
for a full screen application and I was wondering if anyone could give
me pointers on double buffering stratigies and how to create custom
buttons/text boxes/menu/text area graphics.  I intend to have this
project finished by the end of the year before I go to college
(depending on how much time the gui/ai take), but I do not know
everything.
If anyone could point me to some tutorials or give me some sample
code pertaining to the methods use to make a graphic skin over the
buttons/text boxes/menues/text areas I would be very apperciative.
Thank you very much for you time.




== 2 of 4 ==
Date:   Sat,   Nov 13 2004 9:42 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 13 Nov 2004 09:13:44 -0800, Mike wrote:

> Sup everyone,

What does 'Sup' mean?  You will find you get a lot more respect 
(and better answers) if you (try to) use proper English.

But more to the point.  Please don't multi-post Mike.
<http://www.physci.org/codes/javafaq.jsp#xpost>

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



== 3 of 4 ==
Date:   Sat,   Nov 13 2004 9:47 am
From: "Mike" <[EMAIL PROTECTED]> 

Sup is another word for "Whats up" or "Hello", I use it because that is
what I see mostly in other groups/chat situations, if it offends you, I
will refrain from using it in the future.  But thank you for the input.




== 4 of 4 ==
Date:   Sat,   Nov 13 2004 10:08 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 13 Nov 2004 09:47:50 -0800, Mike wrote:

> Sup is another word for "Whats up" 

Duh!  (slaps forehead)

>..or "Hello", I use it because that is
> what I see mostly in other groups/chat situations, if it offends you, 

It does not *offend* me, but..

>..I will refrain from using it in the future.  

I would appreciate that.*  These groups are frequented by a large
number of people for whom English is a second language.  Anything
that helps people to understand each other has to be a good thing.

* Perhaps I should comment that I myself use quite ..interesting
abbreviations at times, but I am careful to *only* use them when in
a conversation with someone that I know will understand them.

>..But thank you for the input.

You're welcome.  

Thanks for accepting my comment graciously, some people
get a little ..upset.   ;-)

Now, I had your question open, ready for a response if I had
the time.  I've found the time, so I'll put some initial thoughts.
Look out for it soon(ish).

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane




==========================================================================
TOPIC: Help needed! how to deploy java application
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1be98d1355247063
==========================================================================

== 1 of 2 ==
Date:   Sat,   Nov 13 2004 9:18 am
From: [EMAIL PROTECTED] (Jane Sfelc) 

Andrew Thompson <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> On 12 Nov 2004 10:42:45 -0800, Brock Heinz wrote:
> 
> > ...I've never
> > really used NetBeans, but I'm guessing there is somewhere that you can
> > determine the JARs in your project's classpath.  
> 
> LOL.  In the time since this thread has been dribbling along,
> another poster popped up on c.l.j.help with Netbeans problems.
> <http://groups.google.com/[EMAIL PROTECTED]>
> (so fresh it is not on Google at time of posting)
> 
> I advised the poster to dump Netbeans*, and they have 
> ..*since then* got their applet not just compiled and running, 
> but jar'd and signed as well. 
> 
> * As I advised on this thread.
> 
> How are you doing, Jane?

Thank you every one for your help ...

After some testing I finally got my app running outside the IDE. The
problem was that my main class primeraapp.PrimerForm used
org.netbeans.lib.awtextra.AbsoluteLayout class, and that class was not
found at runtime. The IDE did not pack that class with my project
files. After looking inside the jdk1.5.0 directory in my system I
found AbsoluteLayout.jar, decompressed it and extracted
AbsoluteLayout.class. The final solution was:

1. Made a directory to store all the classes on my project.
2. Put my application PrimerForm.class inside a \primeraapp directory.
3. Put AbsoluteLayout.class inside \org\netbeans\lib\awtextra
directory.
4. From the root directory, typed: java primeraapp.PrimerForm
5. The application is running!!!

I think NetBeans is not that bad. I followed your suggestions and got
some very nice books on Java programming.

Hope my experience helps other people too.

Bye,

- Jane



== 2 of 2 ==
Date:   Sat,   Nov 13 2004 9:53 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 13 Nov 2004 09:18:12 -0800, Jane Sfelc wrote:

> ..I think NetBeans is not that bad.

Don't get me wrong, I have nothing against powerful, 
intuitive IDEs as such.  It's just that people learning 
Java should know how to compile, run and jar their projects 
before they allow an IDE to 'do it for them'.

Why?  Because the IDE's config. will become corrupted or lost,
and if you don't know how these things are done from the command 
line, your chances of fixing the IDE are pretty slim.

Also, the layout you are using is a horrid one, and I can
say that without having ever used it.  It (correct me if 
I'm wrong) put's things *exactly* where you want them, right? 

That might work fine on one OS, using one particular version
of Java, but move it anywhere else and you will discover that 
the text of UI elements is a different size, or the default 
borders and paddings have changed because of an updated PLAF.
The UI 'falls apart'.

In any case, glad you sorted this one.  Think about what I've 
said for the next problem that crops up.

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane




==========================================================================
TOPIC: java 1.5.0
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b71406a950424de0
==========================================================================

== 1 of 3 ==
Date:   Sat,   Nov 13 2004 9:49 am
From: "Bill Cunningham" <[EMAIL PROTECTED]> 

    Is this new release of Java going to bring about the end of development
of java for win98 users?

    Bill






== 2 of 3 ==
Date:   Sat,   Nov 13 2004 9:57 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Sat, 13 Nov 2004 12:49:40 -0500, Bill Cunningham wrote:

>     Is this new release of Java going to bring about the end of development
> of java for win98 users?

Why should it?  I am developing a 1.1 comptible applet at the 
moment using the 1.5 SDK.  Or are you suggesting Java programmers
will dump earlier Java versions in droves just do they can play
with Generics?

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



== 3 of 3 ==
Date:   Sat,   Nov 13 2004 10:20 am
From: Mark Thornton <[EMAIL PROTECTED]> 

Bill Cunningham wrote:

>     Is this new release of Java going to bring about the end of development
> of java for win98 users?
> 
>     Bill
> 
> 
> 

Why should it? Windows 98 is still listed as a supported system 
configuration for 1.5 (j2SE5).

Mark Thornton




==========================================================================
TOPIC: How do you cast to array?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/884dee2def4bbb47
==========================================================================

== 1 of 1 ==
Date:   Sat,   Nov 13 2004 10:10 am
From: NOBODY <[EMAIL PROTECTED]> 

> The question is: /how/ expensive ?
> 
> Go on, take a guess.  How many milliseconds ? Or is it measured in
> microseconds ?  Or even nanoseconds ?  Take a guess, before you read
> on... 
[...]
> I don't entirely disagree with you that "'new' is expensive", I think
> that a better way to express it (for general purposes) is that 'new'
> is /cheap/. 

The use of antonyms doesn't make it better: 'new' isn't cheap.

Your test:
100M arrays allocated in 3.515 seconds, total size: 0
zero arrays allocated in 0.204 seconds, total size: 0

You just prooved my point, one loop is 15 times faster than the other.
Hang on, see where I'm going now?

If you had another way to get an array to work with, other than a 'new' 
one, the loop would be faster as long as your cache lookup isn't slow.

Allright. You want a test?
Go ahead: and fill and empty an hashmap with 'new' Integer keys from 1 to 
1000 many times.
Canonicalize your integers and you get ~30% throughput increase.


(line #1 is the import)
-----------------------------------
import java.util.HashMap;

public class TestNewCost {
        
        static final Integer[] INTEGERCACHE = new Integer[1000];
        static {
                for (int i = 0; i < 1000; i++) {
                        INTEGERCACHE[i] = new Integer(i);
                }
        }
        
        private static final double mem() {
                Runtime r = Runtime.getRuntime();
                return 0.000001* (r.totalMemory() - r.freeMemory());            
        }
        
        static void relax() throws Exception {
                System.out.println("relaxing...");
                System.gc(); System.out.println(mem());
                System.gc(); System.out.println(mem());
                Thread.sleep(4000); //relax time
                System.gc(); System.out.println(mem());
                System.out.println("relaxing done.");
        }
        
        public static void main(String[] args) throws Exception {
                relax();
                int n = 30000;
                TestNewCost t = new TestNewCost();
                
                System.out.println("!");
                t.test1(n);
                t.test2(n);
                
                System.out.println("!");
                t.test1(n);
                t.test2(n);
                
                relax();
                System.out.println("!");
                t.test1(n);
                t.test2(n);
        }
        
        //---------------------------------
        
        HashMap map = new HashMap();
        
        
        void test1(int n) {
                map.clear();
                long t, d;
                Integer x;
                t = System.currentTimeMillis();
                
                for(int i=0; i<n; i++) {
                        for(int j=0; j<1000; j++) {
                                x = new Integer(j);
                                map.put(x, null);
                        }
                        for(int j=0; j<1000; j++) {
                                x = new Integer(j);
                                map.remove(x);
                        }
                }
                d = System.currentTimeMillis() - t;
System.out.println("test1: "+d+" ms, avg = "+(1000.0*d/n/2000)+" us");
        }
        
        void test2(int n) {
                map.clear();
                long t, d;
                Integer x;
                t = System.currentTimeMillis();
                for(int i=0; i<n; i++) {
                        for(int j=0; j<1000; j++) {
                                x = INTEGERCACHE[j];
                                map.put(x, null);
                        }
                        for(int j=0; j<1000; j++) {
                                x = INTEGERCACHE[j];
                                map.remove(x);
                        }
                }
                d = System.currentTimeMillis() - t;
System.out.println("test2: "+d+" ms, avg = "+(1000.0*d/n/2000)+" us");
        }
}
-----------------------------------------

(sampling mode profile, 1ms, last 2 tests only (after warmup))


Description of CPU usage for thread main 
   57.68% - 8437.0 ms - TestNewCost.main() (TestNewCost.java:41)
      28.75% - 4206.0 ms - TestNewCost.test1() (TestNewCost.java:59)
      16.23% - 2374.0 ms - TestNewCost.test1() (TestNewCost.java:63)
      6.49% - 950.0 ms - TestNewCost.test1() (TestNewCost.java:62)
      3.73% - 546.0 ms - TestNewCost.test1() (TestNewCost.java:58)
      1.29% - 189.0 ms - TestNewCost.test1() (TestNewCost.java:57)
      1.17% - 172.0 ms - TestNewCost.test1() (TestNewCost.java:61)
   41.98% - 6141.0 ms - TestNewCost.main() (TestNewCost.java:42)
      21.89% - 3202.0 ms - TestNewCost.test2() (TestNewCost.java:78)
      16.12% - 2359.0 ms - TestNewCost.test2() (TestNewCost.java:82)
      1.51% - 221.0 ms - TestNewCost.test2() (TestNewCost.java:80)
      0.86% - 126.0 ms - TestNewCost.test2() (TestNewCost.java:76)
      0.84% - 124.0 ms - TestNewCost.test2() (TestNewCost.java:77)
      0.74% - 109.0 ms - TestNewCost.test2() (TestNewCost.java:81)
   0.32% - 48.0 ms - TestNewCost.main() (TestNewCost.java:39)
      0.21% - 32.0 ms - TestNewCost.relax() (TestNewCost.java:21)
      0.1% - 16.0 ms - TestNewCost.relax() (TestNewCost.java:22)


Hot spots
---------

Name                                    Percentage      Time            
--------------------------------------- ----------      ---------       
TestNewCost.test1 (TestNewCost.java:59) 28.75           4206.0 ms       
TestNewCost.test2 (TestNewCost.java:78) 21.89           3202.0 ms       
TestNewCost.test1 (TestNewCost.java:63) 16.23           2374.0 ms       
TestNewCost.test2 (TestNewCost.java:82) 16.12           2359.0 ms       
TestNewCost.test1 (TestNewCost.java:62) 6.49            950.0 ms        
TestNewCost.test1 (TestNewCost.java:58) 3.73            546.0 ms        
TestNewCost.test2 (TestNewCost.java:80) 1.51            221.0 ms        
TestNewCost.test1 (TestNewCost.java:57) 1.29            189.0 ms        
TestNewCost.test1 (TestNewCost.java:61) 1.17            172.0 ms        
TestNewCost.test2 (TestNewCost.java:76) 0.86            126.0 ms        
TestNewCost.test2 (TestNewCost.java:77) 0.84            124.0 ms        
TestNewCost.test2 (TestNewCost.java:81) 0.74            109.0 ms        
TestNewCost.relax (TestNewCost.java:21) 0.21            32.0 ms         
TestNewCost.relax (TestNewCost.java:22) 0.1             16.0 ms         






==========================================================================
TOPIC: Memory sensitive caches
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/847960ed2b3fe4f4
==========================================================================

== 1 of 1 ==
Date:   Sat,   Nov 13 2004 10:50 am
From: Mehmet Erdem <[EMAIL PROTECTED]> 

Mark McKay wrote:
> I have a large number of objects I load from disk and cache in a
> HashMap.  I'd like to know if the JVM is about to run out of memory,
> and if so to then clear the eldest entries out of this cache.  That
> is, I'd like to be notified that an OutOfMemory error is about to be
> thrown, and add some custom handling to try and free up space to
> prevent it.

I do not think it is possible to get notified when an OutOfMemory error 
is about to be thrown.

> 
> I've tried doing this with SoftReferences, but they're being cleared
> long before I run out of memory.
> 
> Is there any way to implement a memory sensitive cache?
> 
> Mark McKay


I recently used a mixture of a LRUMap and a ReferenceMap (you can find 
both in org.apache.commons.collections). The reference map is there to 
hold as many objects as possible within the available memory (same as 
your soft reference map) and the lru map contains a fixed (far smaller) 
amount of the those who were last recently used. You only have to make 
sure to update the lru map everytime you access an object within the 
reference map. In this way your cache will only loose those entries 
which have not been used recently.






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

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

comp.lang.java.programmer
[EMAIL PROTECTED]

Change your subscription type & other preferences:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

Report abuse:
* send email explaining the problem to [EMAIL PROTECTED]

Unsubscribe:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe


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

Reply via email to