comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Scheduled Task in J2EE - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a6228c0f82abecc8 * re. the Enumeration interface. - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/82c0021921f12557 * help with JDBC - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a4767f119aa3583b * Calling Overridden Methods without super - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b323ca46ffc0fc37 * Socket Programming - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/47f5c36e2ad07276 * Is there a better parser (writen in java) than Jtidy? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/730b70675cf88346 * store whole InputStream in a String - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d510835287103e9 * reuse HashMap$Entry (or HashMap in total) to avoid millions of allocations - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6d3d5d296d63ef30 * System.ext() - 7 messages, 4 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6008bc2e14d4e02e * Java 1.5 to be released with nasty JEditorPane/HTML bug - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/18cd37410728e7bc * Why this method behaves differently? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f14afd9d997d1896 ========================================================================== TOPIC: Scheduled Task in J2EE http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a6228c0f82abecc8 ========================================================================== == 1 of 2 == Date: Sat, Sep 11 2004 2:01 am From: [EMAIL PROTECTED] (Ian Walsh) Hi, I'm involved in a Java development project, and have to write an application that runs every night. The infrastructure is Websphere Server on a Regatta box. If I was doing this in Windows using .Net I'd write a Windows Service. What are the options in J2EE? Any help appreciated. Thanks. == 2 of 2 == Date: Sat, Sep 11 2004 8:53 am From: [EMAIL PROTECTED] (Nathan Zumwalt) I'm not sure what a Regatta box is, but if it runs a Unix derivative, you can create a cron job that makes a call to your Websphere app server (EJB, webservices, etc) nightly. Or, you could create a startup class that creates a thread that wakes up every night. Personally, I'd go for the cron job. //Nathan [EMAIL PROTECTED] (Ian Walsh) wrote in message news:<[EMAIL PROTECTED]>... > Hi, > > I'm involved in a Java development project, and have to write an > application that runs every night. The infrastructure is Websphere > Server on a Regatta box. > > If I was doing this in Windows using .Net I'd write a Windows Service. > What are the options in J2EE? > > Any help appreciated. Thanks. ========================================================================== TOPIC: re. the Enumeration interface. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/82c0021921f12557 ========================================================================== == 1 of 3 == Date: Sat, Sep 11 2004 2:10 am From: Michael Borgwardt <[EMAIL PROTECTED]> Steve R. Burrus wrote: > Is the Enumeration interface archaic/deprecated by now??? If so, just > what are the proper methods that should be used now for whatever > replaced it some time ago???!!! I am trying to use Enumeration in a > particular servlet right now, but get compiler errors when it's > referenced in the servlet. Even though it has been replaced by Iterators, Enumeration is not officially deprecated and its usage as such should produce neither compiler errors nor warnings. == 2 of 3 == Date: Sat, Sep 11 2004 3:02 am From: "Steve Cassidy" <[EMAIL PROTECTED]> "Steve R. Burrus" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is the Enumeration interface archaic/deprecated by now??? If so, just <> > particular servlet right now, but get compiler errors when it's referenced > in the servlet. The compiler may not be be able to find the Enumeration class. Try includng import java.util.Enumeration; or import java.util.*; at the top you your class, or in the code try declaring the enumeration as java.util.Enumeration rather than just Enumeration. The import statement just lets you reference classes without putting their package names in front. If you look at the top of your servlet code, you'll probably see import javax.servlet.http.* - this is what's letting you reference HttpServletRequest etc in your doGet() declaration rather than having to type out javax.servlet.http.HttpServletRequest. That's what "import" is for. HTH. == 3 of 3 == Date: Sat, Sep 11 2004 3:43 am From: [EMAIL PROTECTED] "Steve R. Burrus" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Is the Enumeration interface archaic/deprecated by now??? If so, just > what are the proper methods that should be used now for whatever > replaced it some time ago???!!! I am trying to use Enumeration in a > particular servlet right now, but get compiler errors when it's > referenced in the servlet. I don't know why you're getting compiler errors; this certainly should not happen due to an interface's deprecation (not that it has been). Javadoc for Enumeration: "NOTE: The functionality of this interface is duplicated by the Iterator interface. In addition, Iterator adds an optional remove operation, and has shorter method names. New implementations should consider using Iterator in preference to Enumeration. " .ed www.EdmundKirwan.com - Home of The Fractal Class Composition ========================================================================== TOPIC: help with JDBC http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a4767f119aa3583b ========================================================================== == 1 of 3 == Date: Sat, Sep 11 2004 3:01 am From: [EMAIL PROTECTED] (Ebrahim) hi guys .. I am using Oracle : JDBC driver to connect to an oracle server . I am reading the cols from the db into a ResultSet . When I program in Eclipse I can read the values from rs.getString(col_name)( the resultset object ) . But the same code does not work when I run my code on my server - Tomcat . It gives the Exception ResultSet.next() was not called . It does not make any sense ... coz it connects fine to the db fine but does not read any values ... BEsides why should ResultSet.Next() be called in the first place ?? (even though I do call it from my program ) Becoz I am reading only 1 row from the DB at a time so why call rs.next() . S O M E O N E P L S E X P L A I N ???????????????? == 2 of 3 == Date: Sat, Sep 11 2004 3:08 am From: "Steve Cassidy" <[EMAIL PROTECTED]> "Ebrahim" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hi guys .. I am using Oracle : JDBC driver to connect to an oracle > It gives the Exception ResultSet.next() was not called . > BEsides why should ResultSet.Next() be called in the first place ?? rs.next() reads a row from the database into the ResultSet. When you first create a ResultSet with statement.executeQuery() or similar, the cursor into the ResultSet is initially positioned at the start, before the first row. Your first call to rs.next() reads the first row - you have to call it even if your query returns only one row. Until you've called this you can't retrieve any values, as there aren't any loaded to retrieve. == 3 of 3 == Date: Sat, Sep 11 2004 9:34 am From: [EMAIL PROTECTED] (Ebrahim) "Steve Cassidy" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > "Ebrahim" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > hi guys .. I am using Oracle : JDBC driver to connect to an oracle > > It gives the Exception ResultSet.next() was not called . > > BEsides why should ResultSet.Next() be called in the first place ?? > > rs.next() reads a row from the database into the ResultSet. When you first > create a ResultSet with statement.executeQuery() or similar, the cursor into > the ResultSet is initially positioned at the start, before the first row. > Your first call to rs.next() reads the first row - you have to call it even > if your query returns only one row. Until you've called this you can't > retrieve any values, as there aren't any loaded to retrieve. thx for clearing that doubt !!! could you also help me with the following : i need to enter values into my Oracle db in chinese . For this I need to set up the Oracle DB in chinese . Since I work for a company , they might not allow me to change the charset for the entire database to UTF-8 but rather only for a specific schema . Can you help me with this ?? Do you know of any other way by which I can enter data in Chinese/Japanese in an ORacle DB ?? Ebrahim B ========================================================================== TOPIC: Calling Overridden Methods without super http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b323ca46ffc0fc37 ========================================================================== == 1 of 1 == Date: Sat, Sep 11 2004 3:10 am From: Joona I Palaste <[EMAIL PROTECTED]> Marco <[EMAIL PROTECTED]> scribbled the following: > Can I call the overridden version of an object's foo() method > outside that object's class, without using super? EG: > class MainProgram { > public static void main(String[] args) { > Beta b = new Beta(); > // I want to invoke Alpha.foo() but on the Beta instance. > // I want to cancel the dynamic binding that makes Beta.foo() > // get called instead > // b.super.foo() <---- obviously doesn't compile > } > } > class Alpha { > public void foo() { System.out.println("inside Alpha.foo()"); } > } > class Beta extends Alpha { > public void foo() { System.out.println("inside Beta.foo()"); } > } > Is this possible? > Marco No, and it shouldn't be. It is Beta's decision whether it wants to use Alpha's foo() or its own, not the calling code's. Allowing code outside the Beta class to influence the binding of its methods breaks the concepts of polymorphism and encapsulation. (If you absolutely insist, you might try using Reflection. Personally, I find any use of Reflection a crude hack. I have never needed to use it anywhere.) -- /-- Joona Palaste ([EMAIL PROTECTED]) ------------- Finland --------\ \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/ "Holy Banana of this, Sacred Coconut of that, Magic Axolotl of the other." - Guardian in "Jinxter" ========================================================================== TOPIC: Socket Programming http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/47f5c36e2ad07276 ========================================================================== == 1 of 1 == Date: Fri, Sep 10 2004 9:06 pm From: "Kathryn Bean" <[EMAIL PROTECTED]> In client/server application with Datagram, a client side sends a message to a server and puts itself to sleep. Can the client receive a replay from the server while sleeping or will the message be lost? How about Stream Socket? Thank you in advance. Kathryn ========================================================================== TOPIC: Is there a better parser (writen in java) than Jtidy? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/730b70675cf88346 ========================================================================== == 1 of 1 == Date: Sat, Sep 11 2004 5:35 am From: "Ike" <[EMAIL PROTECTED]> you might want to give javacc a try. -Ike "mike" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > regard: > > i use Jtidy to translate HTML file into XHTML file,but Jtidy cannot > do good with complicated HTML files. > > Is there a better parser to translate HTML files into XHTML files? > > thank you ========================================================================== TOPIC: store whole InputStream in a String http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d510835287103e9 ========================================================================== == 1 of 3 == Date: Sat, Sep 11 2004 5:37 am From: "<- Chameleon ->" <[EMAIL PROTECTED]> Can I write all contents of an InputStream to a String at once? something like String a = inputStream.readAll(); == 2 of 3 == Date: Sat, Sep 11 2004 6:27 am From: "ak" <[EMAIL PROTECTED]> > Can I write all contents of an InputStream to a String at once? > > something like > > String a = inputStream.readAll(); > sure: public String readAll(InputStream inputStream) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); byte [] buffer = new byte[1024]; while(true) { int len = inputStream.read[buffer]; if(len < 0) { break; } bout.write(buffer, 0, len); } byte [] data = bout.toByteArray(); return new String(data); } String a = readAll(in); -- Andrei Kouznetsov http://uio.dev.java.net Unified I/O for Java http://reader.imagero.com Java image reader == 3 of 3 == Date: Sat, Sep 11 2004 8:36 am From: Paul Lutus <[EMAIL PROTECTED]> ak wrote: >> Can I write all contents of an InputStream to a String at once? >> >> something like >> >> String a = inputStream.readAll(); >> > sure: > > public String readAll(InputStream inputStream) { > ByteArrayOutputStream bout = new ByteArrayOutputStream(); > byte [] buffer = new byte[1024]; > while(true) { > int len = inputStream.read[buffer]; > if(len < 0) { > break; > } > bout.write(buffer, 0, len); > } ??? Please consider the following, and avoid constructions like "while(true)" and "break" when possible: int len; while((len = inputStream.read[buffer]) > 0) { bout.write(buffer, 0, len); } -- Paul Lutus http://www.arachnoid.com ========================================================================== TOPIC: reuse HashMap$Entry (or HashMap in total) to avoid millions of allocations http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6d3d5d296d63ef30 ========================================================================== == 1 of 2 == Date: Sat, Sep 11 2004 6:51 am From: Frank <[EMAIL PROTECTED]> Vince Darley wrote: > Now, the problem with this is that the code spends 40%+ of its time > allocating new HashMap$Entry objects (according the profiling we've > done) I'm sure you're reading your profiling data wrong. Here's a dump from code which basically does nothing but add items to a hashmap. As you can see, HashMap$Entry.<init> doesn't show up until 11th, at 1.67% CPU time. Map.put() is bound to take some time, but perhaps you can shave off a few % by using a larger initial capacity. CPU TIME (ms) BEGIN (total = 940616) Sat Sep 11 15:45:33 2004 rank self accum count trace method 1 32.60% 32.60% 1 301225 Q.main 2 30.27% 62.87% 5300314 301127 java.util.HashMap.put 3 11.31% 74.18% 5300314 301126 java.util.HashMap.addEntry 4 5.43% 79.62% 5300314 301123 java.util.HashMap.hash 5 5.40% 85.02% 1234 301130 java.util.HashMap.resize 6 5.22% 90.24% 1234 301129 java.util.HashMap.transfer 7 2.33% 92.57% 7262242 301128 java.util.HashMap.indexFor 8 1.73% 94.30% 5300314 301124 java.util.HashMap.indexFor 9 1.70% 95.99% 5300314 301122 java.lang.Integer.hashCode 10 1.70% 97.69% 5300314 301121 java.util.HashMap.maskNull 11 1.67% 99.36% 5300314 301125 java.util.HashMap$Entry.<init> 12 0.10% 99.46% 2 301089 java.lang.Object.wait >, and manages to allocate some 33 million of them (>1 Gb of > memory in total), although certainly no more than 1/2 million are > active at any one time (say 10-20Mb, according to the profiler). The garbage collector may not be working too hard when there's plenty of free heap. Specify a heap size for the JVM if your program is laying claim on too much system resources. -Frank == 2 of 2 == Date: Sat, Sep 11 2004 8:37 am From: "Jeff" <[EMAIL PROTECTED]> We had the same concern. First, our analysis did not show the creation of entry as a big time consumer. Our profiling did not indicate it, nor did our discussions with the JVM providers. Object creation is reasonably fast. Second, you could consider writing your own HashMap as another contributor suggested. java.util.HashMap uses an array for storage. You could use those methods as a starting point for your own class's methods. "Vince Darley" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > An application we've built makes very extensive use of > java.util.HashMaps to store the results of 10s of thousands of > calculations it does. Each of those calculations involves reading > from/writing to a HashMap, eventually filling it with, say, > 10000-100000 entries. Once complete, the information is copied out > into a fixed matrix, and we can safely discard the HashMap (and all > its entries of course). > > Now, the problem with this is that the code spends 40%+ of its time > allocating new HashMap$Entry objects (according the profiling we've > done), and manages to allocate some 33 million of them (>1 Gb of > memory in total), although certainly no more than 1/2 million are > active at any one time (say 10-20Mb, according to the profiler). > > So, my question is: are there any suggestions for how we can > restructure this code or its use of HashMap to avoid such a mad > allocation/deallocation frenzy. It would all, presumably, run more > quickly if we could avoid this problem. > > Any ideas? > > Vince. ========================================================================== TOPIC: System.ext() http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6008bc2e14d4e02e ========================================================================== == 1 of 7 == Date: Sat, Sep 11 2004 6:58 am From: steph <[EMAIL PROTECTED]> Hello, Is the any way to prevent a class to do a System.exit() i.e: in my application, i invoque a gui with an 'exit' button and i don't want to stop the jvm when clicking on this button thanks. -- stephane retirez les lettres majuscules et le 666 de l'adresse pour l'utiliser. remove uppercase letters and 666 from email address to use. == 2 of 7 == Date: Sat, Sep 11 2004 7:18 am From: Mark Thornton <[EMAIL PROTECTED]> steph wrote: > Hello, > > Is the any way to prevent a class to do a System.exit() > > i.e: in my application, i invoque a gui with an 'exit' button and i > don't want to stop the jvm when clicking on this button > > thanks. Install a SecurityManager (not always possible) and rejects attempts to call System.exit. The problem here is that you can't install a SecurityManager if one has already been installed. Mark Thornton == 3 of 7 == Date: Sat, Sep 11 2004 8:45 am From: Andrew Thompson <[EMAIL PROTECTED]> On Sat, 11 Sep 2004 15:58:41 +0200, steph wrote: > Is the any way to prevent a class to do a System.exit() Yes. Do not call System.exit() in your code. > i.e: in my application, With or without a GUI? > ..i invoque a gui with an 'exit' button Why would you invoke a GUI with a button labelled 'exit'? >..and i don't want > to stop the jvm when clicking on this button So don't. (To get more meaningful answers, you are going to need to make more sense) -- Andrew Thompson http://www.PhySci.org/ Open-source software suite http://www.PhySci.org/codes/ Web & IT Help http://www.1point1C.org/ Science & Technology == 4 of 7 == Date: Sat, Sep 11 2004 8:54 am From: Mark Thornton <[EMAIL PROTECTED]> Andrew Thompson wrote: > On Sat, 11 Sep 2004 15:58:41 +0200, steph wrote: > > >>Is the any way to prevent a class to do a System.exit() > > > Yes. Do not call System.exit() in your code. > > >>i.e: in my application, > > > With or without a GUI? > > >>..i invoque a gui with an 'exit' button > > > Why would you invoke a GUI with a > button labelled 'exit'? > > >>..and i don't want >>to stop the jvm when clicking on this button > > > So don't. > > (To get more meaningful answers, you > are going to need to make more sense) > I presume that he is calling some gui code that he didn't write or doesn't have permission to modify. That gui code has an exit button which invokes System.exit. He wants to be able to stop that gui code from terminating the VM. Its a nasty problem which arose originally from the need for any GUI code to use System.exit if the application was ever to exit. This is no longer necessary as the gui threads will now terminate once there are no active frames. However there is still a lot of code which still uses System.exit. It is easy to make sense of this request if you recognise the symptoms of the dilemma. Mark Thornton == 5 of 7 == Date: Sat, Sep 11 2004 9:22 am From: Andrew Thompson <[EMAIL PROTECTED]> On Sat, 11 Sep 2004 16:54:12 +0100, Mark Thornton wrote: > It is easy to make sense of this request if you recognise the symptoms > of the dilemma. Or if it's put the way you put it. -- Andrew Thompson http://www.PhySci.org/ Open-source software suite http://www.PhySci.org/codes/ Web & IT Help http://www.1point1C.org/ Science & Technology == 6 of 7 == Date: Sat, Sep 11 2004 9:24 am From: Andrew Thompson <[EMAIL PROTECTED]> On Sat, 11 Sep 2004 15:18:04 +0100, Mark Thornton wrote: > steph wrote: .. >> Is the any way to prevent a class to do a System.exit() .. > Install a SecurityManager (not always possible) and rejects attempts to > call System.exit. The problem here is that you can't install a > SecurityManager if one has already been installed. Can't you install a more retricted security manager? I thought it was simply that you could not install a new security manager with more/wider permissions than the parent. -- Andrew Thompson http://www.PhySci.org/ Open-source software suite http://www.PhySci.org/codes/ Web & IT Help http://www.1point1C.org/ Science & Technology == 7 of 7 == Date: Sat, Sep 11 2004 9:42 am From: Sudsy <[EMAIL PROTECTED]> Andrew Thompson wrote: > On Sat, 11 Sep 2004 15:18:04 +0100, Mark Thornton wrote: > > >>steph wrote: > > .. > >>>Is the any way to prevent a class to do a System.exit() >> > .. > >>Install a SecurityManager (not always possible) and rejects attempts to >>call System.exit. The problem here is that you can't install a >>SecurityManager if one has already been installed. > > > Can't you install a more retricted security > manager? I thought it was simply that you > could not install a new security manager with > more/wider permissions than the parent. > From the javadocs for System#setSecurityManager: "If there is a security manager already installed, this method first calls the security manager's checkPermission method with a RuntimePermission("setSecurityManager") permission to ensure it's ok to replace the existing security manager. This may result in throwing a SecurityException." So a security manager can only be replaced if it allows itself to be replaced. ========================================================================== TOPIC: Java 1.5 to be released with nasty JEditorPane/HTML bug http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/18cd37410728e7bc ========================================================================== == 1 of 2 == Date: Sat, Sep 11 2004 7:17 am From: Tor Iver Wilhelmsen <[EMAIL PROTECTED]> "Larry Barowski" <larrybarATengDOTauburnDOTeduANDthatISall> writes: > I would suggest voting for this bug, but it is marked as "Closed, > fixed" - in "mustang", which I guess is 1.6. I would rather guess 1.5.1; 1.6 is at least 18 months away using the "standard" release schedule. == 2 of 2 == Date: Sat, Sep 11 2004 7:16 am From: Mark Thornton <[EMAIL PROTECTED]> Tor Iver Wilhelmsen wrote: > "Larry Barowski" <larrybarATengDOTauburnDOTeduANDthatISall> writes: > > >>I would suggest voting for this bug, but it is marked as "Closed, >>fixed" - in "mustang", which I guess is 1.6. > > > I would rather guess 1.5.1; 1.6 is at least 18 months away using the > "standard" release schedule. Unfortunately Mustang is indeed 1.6 (or 6.0 now). I don't know if a code name has been allocated for (1.)5.1. Important fixes currently labeled as Mustang may be migrated to what ever they choose to call 5.1. Mark Thornton ========================================================================== TOPIC: Why this method behaves differently? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f14afd9d997d1896 ========================================================================== == 1 of 1 == Date: Sat, Sep 11 2004 8:30 am From: [EMAIL PROTECTED] (otsarri) I think I got it! At least I know now what's going on. I'll try both of the solutions and see which one suits me best. Many thanks, Otsarri ======================================================================= 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 ------------------------ Yahoo! Groups Sponsor --------------------~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/BCfwlB/TM --------------------------------------------------------------------~-> <a href=http://English-12948197573.SpamPoison.com>Fight Spam! Click Here!</a> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/kumpulan/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
