comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Correct Semaphore Implementation in Java -InterruptedException - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8259aec1ceed4f8f * Really simple: how to call a class from another class - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a159dd89d802c683 * Let a runtime exception go beyond a Thread? - 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cd0b7eae55d576e3 * Synchronized block is accessed by other jsps - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e19df43edcc6f04f * Array referencing - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1e5bd96d75c26308 * tricky+frustrating: changing mouse handler while mouse pressed doesn't work - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d860374b64c95232 * Importing Address Book contacts - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fa6b04b8af714f76 * JSP Workflow FlowControl PageFlow Engine - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/acd037da0d51e674 * Which is better... performance- and memory-wise? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bb866c6ac7a64180 * Nested xml tag - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/af8d1dae60232a83 * opinion on coding standard - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1f96751a1d317c1a * Configure a singleton - 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7e33c5a6bd77128b * any easy way to write out a XML DOM object to file? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5f6b296065e077c6 * create stand alone application - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aa0f7e4767471263 * Java Logging API problems - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4e591362f16a57e1 * How to use Transactions in stateless session bean? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ee73b722c1d5e795 * [J2ME]How to avoid memory fragmentation - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cb6a26addf63af68 * Send and retrieve pictures from my computer at home using my cell - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/06e9842e6a7341b7 ============================================================================== TOPIC: Correct Semaphore Implementation in Java -InterruptedException http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8259aec1ceed4f8f ============================================================================== == 1 of 2 == Date: Thurs, Nov 25 2004 12:17 pm From: [EMAIL PROTECTED] (Frank Gerlach) > Also, in many of the real applications I have worked on, Interrupted > Exceptions are not "should never happen" but a real fact of life and need > real handling. Shouldn't your design include something more meaningful, > such as either directly throwing InterruptedException so the application can > determine the appropriate course of action or something that lets them be > ignored or retried? I googled InterruptedException and cam up with this page: http://www.milk.com/java-rants/rant01-interrupted.html It basically states that the exception ONLY occurs when someone in the same VM calls Thread.interrupt() on the thread in question. This page also discusses four options of how to handle the exception. One is to consume it (like I do, with an error message that points to the error of using Thread.interrupt()), another is to rethrow it. I concede that throwing an exception might be a viable option IF you really need to call Thread.interrupt(). == 2 of 2 == Date: Thurs, Nov 25 2004 9:11 pm From: "xarax" "Frank Gerlach" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Matt Humphrey" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > > "Frank Gerlach" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > There seem to be quite a number of not very clean and simple > > > implementations > > > of java Semaphores in the internet. The following example is extremely > > > simple (the Java 1.5 implementation is overfeatured IMHO) and correct: > > > > > > /** Semaphore class for managing limited resources (such as database > > > * connections) > > > * Author: Frank Gerlach ([EMAIL PROTECTED]) > > > * Copyright: None. Use in any way you want. > > > * located at: http://www.geocities.com/gerlachfrank/Semaphore.java > > > */ > > > public class Semaphore{ > > > int count; > > > /** Create the semaphore > > > * @param initialcount number of resource items to manage > > > */ > > > public Semaphore(int initialcount){ > > > count=initialcount; > > > } > > > > > > /** Acquire one resource item > > > */ > > > public void P(){ > > > synchronized(this){ > > > if(count==0){ > > > try{ > > > wait(); > > > }catch(InterruptedException ie){ > > > //this should never happen > > > System.err.println("caught InterruptedException in > > > wait()"); > > > } > > > > I havn't worked with this for a while, but shouldn't it be > > while (count == 0) { > > > > because otherwise the arrival of a spurrious notify will cause the semaphore > > to be granted when it is not yet ready. Alternatively (or in addition), > > shouldn't the monitor be a private instance object and not "this" for > > exactly the same reason? > The while() loop is NOT necessary. Actually, the notify() can only reach > the wait()ing thread when it already sleeps. This is assured by > synchronized(this) > ,which acquires the monitor. Any notify()ing thread must first acquire the > monitor, which is not possible while the thread still runs in P(). /snip/ The call to wait() releases the monitor. Think about what could happen when multiple threads are calling P(). The multiple threads will call wait(). Another thread will subsequently call notify(), which will randomly awaken one of the threads, not necessarily the first thread that chronologically entered P(). Upon awakening, the thread will then re-acquire the monitor. The "while(count==0)" is required. ============================================================================== TOPIC: Really simple: how to call a class from another class http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a159dd89d802c683 ============================================================================== == 1 of 2 == Date: Thurs, Nov 25 2004 12:24 pm From: [EMAIL PROTECTED] (Loic) hello sorry but it's been a long time since I programmed in java and have had a mind block. I have a separate class in the same program folder, called decode.java and I want to send it a string from the main class which is called read.java. The main method in decode.java is expecting a string: public static void main(String binarydata){ //code } so what do I do in read.java to send it this data? sorry for my ignorance! == 2 of 2 == Date: Thurs, Nov 25 2004 9:30 pm From: "Heiner Kücker" Loic wrote > sorry but it's been a long time since I programmed in java and have > had a mind block. I have a separate class in the same program folder, > called decode.java and I want to send it a string from the main class > which is called read.java. The main method in decode.java is expecting > a string: > > public static void main(String binarydata){ > //code > } > > so what do I do in read.java to send it this data? This will not work. Write public static void main( String[] args ) { if ( args.length > 0 ) { System.out.println( args[ 0] ); } } The Parameter in String array args is the command line parameter. java xxx Test Or set the command line parameter in your ide run options. Heiner Kuecker Internet: http://www.heiner-kuecker.de JSP WorkFlow FlowControl Navigation: http://www.control-and-command.de Expression Parser: http://www.heinerkuecker.de/Expression.html ============================================================================== TOPIC: Let a runtime exception go beyond a Thread? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cd0b7eae55d576e3 ============================================================================== == 1 of 2 == Date: Thurs, Nov 25 2004 9:49 pm From: Jaap de Bergen Hello all, I'm using a O/R framework which throws a runtimeexception when something goes wrong (for example a column is missig from the database). A couple of facts: I've made a couple of DAO's which access the O/R framework. The DAO's are being accessed by a Thread. I'm starting my application with the following code: App a=new App(); I try to catch the runtimeexceptions which the O/R framework throws at the root of my program: try{ App a=new App(); } catch(Runtimeexception e){ displayDialog(e)' } That was a good idea, but it doesn't work. I guess because when i launch a thread: MyThreadt=new MyThread(); t.start() MyThread extends Thread{ public void run(){ DAO.accesDAOfunction(); } } and call a DAO function in that thread the runtimeexception will not go further "upwards" then MyThread. In other words it will never reach: try{ App a=new App(); } catch(Runtimeexception e){ displayDialog(e)' } Does anybody know how i can get the runtimeexception reach the root of my application? Kind regards, Jaap == 2 of 2 == Date: Thurs, Nov 25 2004 10:13 pm From: Jaap de Bergen On Thu, 25 Nov 2004 21:49:04 +0100, Jaap de Bergen <[EMAIL PROTECTED]> wrote: > >try{ >App a=new App(); >} >catch(Runtimeexception e){ >displayDialog(e)' >} > >Does anybody know how i can get the runtimeexception reach the root of >my application? > I've wrote a little example to illustrate the problem: =========== import java.awt.*; public class ExceptTest { public static void main(String[] args) { try{ ExceptTest et = new ExceptTest(); } catch(RuntimeException e){ System.out.println("runtime exception: "+e.getMessage()); } } public ExceptTest() { new Worker().work(); } class Worker{ void work(){ MyThread mt=new MyThread(); mt.start(); } } class MyThread extends Thread{ public void run(){ DoSomething o=new DoSomething(); o.doIt(); System.out.println("Ready"); } } class DoSomething{ void doIt(){ throw new RuntimeException("boooe!"); } } } =========== The doIt() function of DoSomething throws a RuntimeException, but this RuntimeException never reaches the "catch(RuntimeException e)" part of the main(String[] args) function. Is there a way to make the RuntimeException get to the main(String[] args) function? Jaap ============================================================================== TOPIC: Synchronized block is accessed by other jsps http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e19df43edcc6f04f ============================================================================== == 1 of 1 == Date: Thurs, Nov 25 2004 12:52 pm From: [EMAIL PROTECTED] (Frank Gerlach) [EMAIL PROTECTED] (biswa) wrote in message news:<[EMAIL PROTECTED]>... > HI. > I have a synchronized block where i am creating a temp table and > deleting it in the same method after processing. I ve to make it a > synchronized to avoid other requests from accessing the temp table > while the other request is processing. > > But strangely, i can see more than one requests entering to the method > at the same time. If there are two requests at the same time, one > tries to delete the temp table while other is accessing. > > How is it possible although the method is synchronized it is accessed > by more than one request at the same time. I am calling the mothod in > JSP file. Am i missing something? > > Any help would be great. Post a short snippet of your code. Most probably you are synchronize()ing on two DIFFERENT object instances. ============================================================================== TOPIC: Array referencing http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1e5bd96d75c26308 ============================================================================== == 1 of 3 == Date: Thurs, Nov 25 2004 9:57 pm From: "Boudewijn Dijkstra" "Andrei Kouznetsov" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] >> Here is my routine. It is not working. Anyone see the problem? >> >> public void test () >> { >> >> String[][] data_1 = { >> { "AA_1", "Hello world" }, >> { "AA_2", "123456789" } >> }; >> String[][] data_2 = { >> { "BB_1", "Bla Bla" }, >> { "BB_1", "222222222" }, >> }; >> String[][] data_3 = { >> { "CC_1", "Happy New Year" }, >> { "CC_1", "333333333" }, >> }; >> >> for(int i=1; i <=3; i++){ >> // following line is wrong. Anyone know how to do it?? >> String data_name[][] = "data_"+i; >> System_out_println(" first = "+data_name[j][0]; >> System_out_println(" second = "+data_name[j][1]; >> } >> } >> > > I suppose you are from VisualBasic world... > > What you can do is following: > > Object [] data = new Object[3]; > data[0] = data_1; > data[1] = data_2; > data[2] = data_3; > > for(int i=0; i < 3; i++){ > String data_name[][] = (String[][]) data[i]; > System_out_println(" first = "+data_name[j][0]; > System_out_println(" second = "+data_name[j][1]; > } Please place your brackets consistently, preferably directly behind the element type when declaring. That goes for the both of you. == 2 of 3 == Date: Thurs, Nov 25 2004 10:29 pm From: "Andrei Kouznetsov" > Please place your brackets consistently, preferably directly behind the > element type when declaring. That goes for the both of you. I just copy/paste his code, I always put brackets in the middle. -- 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 == 3 of 3 == Date: Thurs, Nov 25 2004 10:59 pm From: Ricardo [EMAIL PROTECTED] wrote: > Hi, > > Here is my routine. It is not working. Anyone see the problem? > > public void test () > { > > String[][] data_1 = { > { "AA_1", "Hello world" }, > { "AA_2", "123456789" } > }; > String[][] data_2 = { > { "BB_1", "Bla Bla" }, > { "BB_1", "222222222" }, > }; > String[][] data_3 = { > { "CC_1", "Happy New Year" }, > { "CC_1", "333333333" }, > }; > > for(int i=1; i <=3; i++){ > // following line is wrong. Anyone know how to do it?? > String data_name[][] = "data_"+i; > System_out_println(" first = "+data_name[j][0]; > System_out_println(" second = "+data_name[j][1]; > } > } It seems you want to reference data_1 array when you say "data_"+i. You cannot do that. Actually you put an String value(/"data_"+i/) in an array, which is wrong. What do want to do would be: public void test () { String[][][] data = { { {"AA_1", "Hello world"}, {"AA_2", "123456789"} }, { {"BB_1", "Bla Bla"}, {"BB_1", "222222222"} }, { {"CC_1", "Happy New Year"}, {"CC_1", "333333333"} }}; for(int i=0; i <=1; i++){ System_out_println(" first = "+data[j][0][i]; System_out_println(" second = "+data[j][1][i]; } } ============================================================================== TOPIC: tricky+frustrating: changing mouse handler while mouse pressed doesn't work http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d860374b64c95232 ============================================================================== == 1 of 1 == Date: Thurs, Nov 25 2004 10:50 pm From: Claus Atzenbeck Hello, I have a quite tricky problem, on that I work on for 3 days now without success. It's frustrating. *sigh* :-( I am using Piccolo, a zoomable UI framework <http://www.cs.umd.edu/hcil/jazz/download/>, to create a 2D space on which I can place different kinds of nodes, e.g., pictures. However, my problem is more general and not Piccolo based. Every node on this 2D space has its own mouse event handler attached. With the mouse event handler you can click on a node and drag it to another place. Every node has internally its unique index ID. If two nodes intersect, then the one with a higher index is displayed above a node with lower index. Currently, you can drag a node anywhere, even underneath another node with higher index. WHAT I WANT: Whenever a node of higher index comes between the dragged node and the cursor, I want to release the original node and apply all mouse events to the higher placed node. If a user would do this manually, he/she would release the mouse button and click again. However, the user is not doing this, but the machine should; the user constantly just holds the mouse button pressed. This turns out to be very difficult to handle, because the user does *not* release the mouse button. The input handler of the node directly underneath the cursor (that *should* handle the mouse events then), does not get activated. :-( Any expert here who can see how to solve this problem? Here is the code. Don't worry about the Piccolo stuff. I think it is a general Java question about mouse events and robots (I use java.awt.Robot -- is this the right approach?). I have marked the problematic part: ******** <code> ******* public void mouseDragged(PInputEvent aEvent) { // This tells other handlers that this event is now already handled now aEvent.setHandled(true); // Find the cursor position and the node position. Point2D cursorPos = aEvent.getPosition(); PBounds nodePosition = aEvent.getPickedNode().getGlobalFullBounds(); // Check if the cursor is within the node's bounds. This is // just for cases when the dragged node is slower than the cursor. if (nodePosition.contains(cursorPos.getX(), cursorPos.getY()) { // This retrieves the node directly underneath the cursor PNode nodeUnderneathCursor = aEvent.getPickedNode().getRoot() .getDefaultInputManager().getMouseOver() .getPickedNode(); // If there is a node underneath the cursor + its not the background if (! nodeUnderneathCursor.equals(aEvent.getPickedNode()) && ! nodeUnderneathCursor.getClass().equals(PCamera.class)) { // HERE IS THE PROBLEMATIC PART!! <<<<<<<<<<<<<<<<<<<<<<<<<<<< // Have in mind that there constantly comes a mouseDragged event // in from the user's pressed mouse button! try { Robot robot = new Robot(); // this should release the mouse button for the original node robot.mouseRelease(InputEvent.BUTTON1_MASK); // Tell other handlers that this one doesn't want to handle anymore aEvent.setHandled(false); // this should perform a click; the position is right on the node // that is between the cursor and the original dragged node robot.mousePress(InputEvent.BUTTON1_MASK); } catch (AWTException e) { e.printStackTrace(); } } } // Move the node to the new cursor position Dimension2D delta = aEvent.getDeltaRelativeTo(aEvent.getPickedNode()); aEvent.getPickedNode().translate(delta.getWidth(), delta.getHeight()); } ******* </code> ******* Thanks a lot for any hint! Claus ============================================================================== TOPIC: Importing Address Book contacts http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fa6b04b8af714f76 ============================================================================== == 1 of 1 == Date: Fri, Nov 26 2004 6:12 am From: steve On Thu, 25 Nov 2004 19:59:46 +0800, [EMAIL PROTECTED] wrote (in article <[EMAIL PROTECTED]>): > Hi, I would like to know if is there a library that gives the > possibility to import Address Book contacts in java. > Not exactly "import", but selecting contacts to use for sending > something. > Also by drag & dropping. > I haven't found anything. > > Thanks yes there is. try a search for "jcard" ============================================================================== TOPIC: JSP Workflow FlowControl PageFlow Engine http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/acd037da0d51e674 ============================================================================== == 1 of 1 == Date: Thurs, Nov 25 2004 11:08 pm From: "Murray" "Heiner Kücker" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all > > Sorry, my englisch is not good. > > I have written an JSP FlowControl Framework called > 'Control and Command'. > So you keep saying. And multiposting. ============================================================================== TOPIC: Which is better... performance- and memory-wise? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bb866c6ac7a64180 ============================================================================== == 1 of 2 == Date: Fri, Nov 26 2004 1:53 am From: Daniel Sjöblom Chris Uppal wrote: > xarax wrote: > >>Also, JIT'd code is supposedly debuggable now, so >>an explicit assignment of a default value should >>not get optimized away by the JIT. > > > It's probably worth clarifying this a little -- it could be misinterpreted. > As > I understand it, the JITer is still allowed to remove the assignment to null > (and for all I know that's what it does), it's just that it's required to /put > it back/ if you place a breakpoint on it. (Chances are it'll put it back if > you place a breakpoint anywhere in that method -- but that's an implementation > detail and I'm /very/ sketchy on the details). I created a little test class, and ran it through a little JVMTI agent that dumps the JIT-generated native code, and I can confirm that at least on the client 1.5.0 JVM on x86 linux, the explicit assignment was not removed in the JIT-ed code. That was the only difference between the compiled code of the two different approaches. The server VM on the same JVM did generate equivalent code for both approaches. I suspect the client VM does not do any dead code elimination. -- Daniel Sjöblom Remove _NOSPAM to reply by mail == 2 of 2 == Date: Fri, Nov 26 2004 12:30 am From: [EMAIL PROTECTED] (Gerbrand van Dieijen) On Wed, 24 Nov 2004 11:47:22 -0500, Dave Stallard wrote: > >for (Iterator i=c.iterator();i.hasNext();) > Object o = i.next(); // You don't need the coercion for Object > >Of course, in the new Java you should be able to write something like: > >foreach (Object : c) > It's not the same, and the first (for (Iterator i) is even incorrect: it will fail when c is empty. You should always use Iterator it=..;while (it...) or the new (and much indeed much better) construct for (... :..) except when you're very sure the collection can never be empty. -- Gerbrand van Dieijen ============================================================================== TOPIC: Nested xml tag http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/af8d1dae60232a83 ============================================================================== == 1 of 1 == Date: Thurs, Nov 25 2004 4:36 pm From: [EMAIL PROTECTED] (terry) Hi, Why could I get the incorrect count of tag elements when the tag is nested? I just write some codes for testing in the following. The debug output count is 6 but I expect that it is 3 as the next 3 are nested. How to solove this? : : Element root=doc.getDocumentElement(); NodeList nl=root.getElementsByTagName("name"); debug.println(nl.getLength()); : : The xml is in the following: <?xml version='1.0' encoding='utf-8'?> <root> <name> All </name> <name> <name> Connector </name> <name> Inline </name> <name> PCB </name> </name> <name> Crystal_and_Resonator </name> </root> ============================================================================== TOPIC: opinion on coding standard http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1f96751a1d317c1a ============================================================================== == 1 of 1 == Date: Fri, Nov 26 2004 12:42 am From: [EMAIL PROTECTED] (Gerbrand van Dieijen) On Tue, 23 Nov 2004 20:40:01 -0500, Hal Rosser wrote: >One thing experience will teach you: >Your job is to do what the boss says. >Oops - gotta go do the dishes now - bye Indeed, if you're boss wants (for example) the new XML thingie, you'll buy it. You won't say 'we don't need it because' or 'an alternative would be' because that's scary and even my advice could save money or be more efficient, my boss already thougth about that - because he should now the same things as I do. This way I'm certain to get promotion :-) -- Gerbrand van Dieijen ============================================================================== TOPIC: Configure a singleton http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7e33c5a6bd77128b ============================================================================== == 1 of 2 == Date: Fri, Nov 26 2004 2:11 am From: "Ferenc Hechler" I think the correct way is to do the initialization in the getInstance() method (only at first call and synchronized). What do you mean with clustered environment? bye, feri "ShadowMan" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > Hi all, > according to your opionion, what is the best way to configure a Singleton > through an external fileName. > I have two solutions: > - using a static method that configures a Singleton and return its > instance > Example: Singleton singleton = Singleton.init(fileName); > > - use a public (not static) method to call directly on instance > > Example: > Singleton singleton = Singleton.getInstance(); > singleton.init(fileName) > > I have to use it on a clustered environment.. > -- > ShadowMan > == 2 of 2 == Date: Fri, Nov 26 2004 2:22 am From: "Ferenc Hechler" OK, my first answer did not match your question: How to pass some config-file-data to a class containing a singleton. For example Log4J uses a default-configuration file "log4j.properties" or so, which is searched in the classpath. But you can change the configuration by explicitly setting the properties from another configuration file (PropertyConfigurator). I think this is a flexible way. Add a method setConfig(...) which overwrites some defaults which are used otherwise. bye, feri "Ferenc Hechler" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] >I think the correct way is to do the initialization in the getInstance() >method (only at first call and synchronized). > What do you mean with clustered environment? > bye, > feri > > "ShadowMan" <[EMAIL PROTECTED]> schrieb im Newsbeitrag > news:[EMAIL PROTECTED] >> Hi all, >> according to your opionion, what is the best way to configure a Singleton >> through an external fileName. >> I have two solutions: >> - using a static method that configures a Singleton and return its >> instance >> Example: Singleton singleton = Singleton.init(fileName); >> >> - use a public (not static) method to call directly on instance >> >> Example: >> Singleton singleton = Singleton.getInstance(); >> singleton.init(fileName) >> >> I have to use it on a clustered environment.. >> -- >> ShadowMan >> > > ============================================================================== TOPIC: any easy way to write out a XML DOM object to file? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5f6b296065e077c6 ============================================================================== == 1 of 1 == Date: Fri, Nov 26 2004 2:28 am From: "Ferenc Hechler" Hello, XMLSerializer is deprecated (old xerces). Some code I use to transform a Document into a String: Document document = ...; DOMSource domSource = new DOMSource(document); StreamResult streamResult = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer serializer = tf.newTransformer(); serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1"); // serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"users.dtd"); serializer.setOutputProperty(OutputKeys.INDENT,"yes"); serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount","4"); serializer.transform(domSource, streamResult); String result = writer.getBuffer().toString(); Best regards, feri ============================================================================== TOPIC: create stand alone application http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aa0f7e4767471263 ============================================================================== == 1 of 1 == Date: Fri, Nov 26 2004 2:33 am From: "Ferenc Hechler" Hello tomer, if you use eclipse you can use the plugin Fat Jar http://fjep.sourceforge.net/ which packs together all project libraries and references into one "fat" jar. If you have an JRE installed under windows you can start this jar by simply double clicking. bye, feri "tomer" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > Hi All > > I need to write an information system, > I wont to write this system with java, the system need stand alone, > I mean that when I run this program I don't wont to run it from a > develpment area, > I want to run it from icon on the desktop. > > maybe I will need a installation program.....(can i do it)? > > Thanks, tomer > ============================================================================== TOPIC: Java Logging API problems http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4e591362f16a57e1 ============================================================================== == 1 of 1 == Date: Fri, Nov 26 2004 1:47 am From: "newguy" Not ot sure about Log api in Java 1.4 But I recently use log4j form apache, works, fine and easier, I believe. "Simor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > Maybe somebody can help me. > I try to use the java logging api in my project, but i doen't want to > use the standard configuration (from /lib/logger.properties) for the > logger. So i set the "java.util.logging.config.file"-property like > this: > System.setProperty("java.util.logging.config.file",System.getProperty("user. dir") > + System.getProperty("file.seperator") + "customproperties"); > > before i create my LogManager like this: > LM = LogManager.getLogManager(); > > But it doesn't work. I got no errormsg, but changes in the > configuration file have no effect on the applications logging > behavior. > > THX > > P.S. I use eclipse 3.1 M2. ============================================================================== TOPIC: How to use Transactions in stateless session bean? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ee73b722c1d5e795 ============================================================================== == 1 of 1 == Date: Thurs, Nov 25 2004 8:54 pm From: Sudsy harry wrote: <snip> > Do I have to create another session bean, this time make it stateful & put > all methods that require transactions in there? or can I still achieve this > using a stateless bean? > > Many thanks - appologies if not correct wording but a bit new to this! Look at the container-transaction element nested within the assembly-descriptor element which is nested in the ejb-jar element. Here's a brief outline of an ejb-jar.xml file: <?xml version="1.0"?> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> <ejb-jar> <enterprise-beans> <session> <ejb-name>MyBean</ejb-name> <home>com.mine.MyBeanHome</home> <remote>com.mine.MyBean</remote> <ejb-class>com.mine.MyBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> </enterprise-beans> <assembly-descriptor> <container-transaction> <method> <ejb-name>MyBean</ejb-name> <method-name>*</method-name> </method> <trans-attribute>Required</trans-attribute> </container-transaction> </assembly-descriptor> </ejb-jar> Looks like you have some reading ahead of you! ;-) -- Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development. ============================================================================== TOPIC: [J2ME]How to avoid memory fragmentation http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cb6a26addf63af68 ============================================================================== == 1 of 1 == Date: Fri, Nov 26 2004 10:00 am From: JScoobyCed DNass wrote: > I have this system error message saying "this application is > using too much memory", I know that the app uses about 150k of RAM > and the mobile has 260 k If the application has pictures, try to decrease their sizes. This will help lowering the app size. Then use an obfuscator to optimize the byte code and reduce again the size. Now if the file received by HTTP is bigger than the available memory, it might crash the app too. JScoobyCed ============================================================================== TOPIC: Send and retrieve pictures from my computer at home using my cell http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/06e9842e6a7341b7 ============================================================================== == 1 of 1 == Date: Thurs, Nov 25 2004 7:07 pm From: [EMAIL PROTECTED] (Jimmy) Thanks. "MaSTeR" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > "Jimmy" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Just wondering if anyone know if telcos (Bell, AT&T Rogers, Telus, > > etc.) provide public WAP Push Gateway or MMS Gateway service in the > > Greater Toronto Area? > > Just recently picked-up a cell phone with camera. I like to send > > pictures directly to my linux box at home, whether is re-directed > > through email or http by telco, so I can delete them from my phone to > > save space. Or, I can load it back from my server at home and see on > > my cell again. > > My linux box already has mail and web server running so I can recieve > > as email or have a little cgi script to save pictures to file. > > You need C++. Java executes in a sandbox and cannot access anything on the > file system except its RMS. Unless you take picture with the program you > intend to use to do the transfers you have to llok somewhere else. ============================================================================== 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
