comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * JTree Directory System - 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/65ea2f59800e25b6 * 'A'++ == 'B': Always True? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bb79b41e32f311b2 * Where is source code for Struts 1.1? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1b5efbaecd3eca9a * CORBA or some other methodology? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a7b217bf697c503b * Garbage from resourceBundle.getObject() for Japanese - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5f206e906199c9ae * applet problem - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/77127616376e3ddd * Which way is more efficient - comparing strings of different letter casing - 6 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3acc767a96f24a10 * Class and interface loading order - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dc413d1e05db6fe * UnsatisfiedLinkError in Eclipse standalone SWT app - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e03dc0d087a5062a * validating classpaths - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9ee9967e34de9e2c * Time conversion problem. - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1726e3482ae3b094 * I wrote my own Java in BASIC ! ! ! - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/29ec22b23b7d5d6d * Writing to Word documents - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/63e6214e752428a * loading a class whose bytecode comes in a byte[] - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4e991c30dd027000 * Is "String s = "abc";" equal to "String s = new String("abc");"? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/57b8aacdcf136f3f * implementing comparable - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9f2d220f347ddff4 * Search for byte pattern in a binary file. - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc671002cbe38f70 * Sun's Java Forums - When Will They Be Back? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ba8f8003d1842a83 * Version 1.3.1 Versus 1.4.2_04 - 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/65e179ef76a09f65 * HTTPUnit not working against an https (SSL) site - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8d793f5e72fb7839 ========================================================================== TOPIC: JTree Directory System http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/65ea2f59800e25b6 ========================================================================== == 1 of 2 == Date: Thurs, Nov 18 2004 10:13 am From: [EMAIL PROTECTED] (seung_shin) "Vincent Cantin" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > You should make a CellRenderer for your tree, it will display the files in a > differet way. Thanks all~ == 2 of 2 == Date: Thurs, Nov 18 2004 2:02 pm From: [EMAIL PROTECTED] (seung_shin) Thanks. It worked!!!! public class FileSystemTreeCellRenderer extends DefaultTreeCellRenderer { public Component getTreeCellRendererComponent(JTree tree, Object value,boolean selected, boolean expanded,boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, selected,expanded, leaf, row, hasFocus); String nodeObject; nodeObject = value.toString(); nodeObject = nodeObject.substring(nodeObject.lastIndexOf("\\")+1); setText(nodeObject); return this; } } ========================================================================== TOPIC: 'A'++ == 'B': Always True? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bb79b41e32f311b2 ========================================================================== == 1 of 2 == Date: Thurs, Nov 18 2004 10:19 am From: "Doug Pardee" <[EMAIL PROTECTED]> A clarification: my posting was trying to combine all of the points from the thread into a single comprehensive posting, while directly refuting the following bit of misinformation: steve> It would break on all south asian languages steve> ( taiwan/China /Japan), I would guess any language steve> using picto- grams ,would mess it up. Now, as to Chris Smith and Michael Borgwardt's discussion: Chris> I think you missed the point of Michael's response. Chris> That was that if the source file was written in a Chris> text editor, and then saved in some encoding that Chris> doesn't represent the character A, Michael> Or represents it in a different way than the Michael> compiler expects. I didn't miss the point at all. I think that Michael's point is not well-taken, and I stated that the hypothesized problem simply can't happen. Chris had already said pretty much the same thing: Chris> it's really impossible to write Java code in a language that Chris> doesn't have at least the basic ASCII characters (even Chris> Unicode escapes require a backslash and the letter u). If you can't generally trust the compiler to implement the Java Language Specification correctly, you're doomed. And specifically, if the compiler can't look at an 'A' in your source code and get it as \u0041, then you'll never be able to catch an ArrayIndexOutOfBoundsException thrown by the JVM. Doug> you'll usually be using a character encoding that Doug> translates 0x0000-0x007F into byte values 0x00-0x7F. Doug> A counter-example would be if Doug> you were running on an IBM mainframe, Chris> I don't think that's relevant. A typical EBCDIC machine would Chris> take a different route to get there, but the resulting output Chris> would still be an 'A' followed by a 'B'. For the simple case of System.out.println() as shown by the OP, I'll agree that it's (virtually) irrelevant. However, it IS relevant if you're running on an EBCDIC machine but working with a non-EBCDIC data stream or I/O device. The example that I already gave was TCP/IP data. Another example that could surprise the programmer would be outputting "RS" to a ByteArrayOutputStream using the default encoding, which can result in the array {0xD9, 0xE2} when run on an EBCDIC machine instead of the {0x52,0x53} the programmer always saw when running on an ASCII machine. The OP (to whom I was responding) was asking an important question about a fundamental difference between the languages that he was accustomed to and Java. Languages like C process characters internally in 'native' form with no translation during I/O, while Java processes characters internally in Unicode and translates during I/O. This difference trips up a LOT of beginning Java programmers, and I felt that it was worthwhile to be explicit about what was going on. == 2 of 2 == Date: Thurs, Nov 18 2004 12:57 pm From: Michael Borgwardt <[EMAIL PROTECTED]> Doug Pardee wrote: > If you can't generally trust the compiler to implement the Java > Language Specification correctly, you're doomed. And specifically, if > the compiler can't look at an 'A' in your source code and get it as > \u0041, then you'll never be able to catch an > ArrayIndexOutOfBoundsException thrown by the JVM. You really didn't get the point. The Java Language Specification isn't even relevant at this point. The source code is originally composed of bytes, not characters. And the compiler has to use some sort of encoding to convert these bytes into characters. It's not the fault of the compiler than it may use a wrong one. ========================================================================== TOPIC: Where is source code for Struts 1.1? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1b5efbaecd3eca9a ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 10:22 am From: [EMAIL PROTECTED] (Andrew Hammer) Does anyone know where I can obtain the source code for Struts 1.1? Now that Struts is an Apache project (not Jakarta) I can't find the source (or bianry) distributions for previous versions. ========================================================================== TOPIC: CORBA or some other methodology? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a7b217bf697c503b ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 10:28 am From: Bruno Grieder <[EMAIL PROTECTED]> Ted Holden wrote: > On Thu, 18 Nov 2004 15:36:08 +0100, Bruno Grieder > <[EMAIL PROTECTED]> wrote: > > > >>Perfectly acceptable security can be achieved with a simple https post >>or get. Now, if you want procedure calls with type marshalling but >>simple stuff, why not XML-RPC? > > > Thanks! > > Can xml-rpc handle an object written in C++, and, if so, where can I > read more about it? > > > > Cannot be simmpler: www.xmlrpc.com and for C/C++ http://xmlrpc-c.sourceforge.net/xmlrpc-howto/xmlrpc-howto-c.html Bruno ========================================================================== TOPIC: Garbage from resourceBundle.getObject() for Japanese http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5f206e906199c9ae ========================================================================== == 1 of 2 == Date: Thurs, Nov 18 2004 10:57 am From: Delia <[EMAIL PROTECTED]> Thomas Weidenfeller <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Delia wrote: >> I tried saving the .properties file in UTF-8, 16 bit unicode (big and >> little endian), but I just get varrying strings of characters that I >> can't figure out where they come from. > > In general, I would suggest you read the documentation for Properties. > There you will find out the following: > > A properties file is supposed to be in ISO Latin-1, and nothing else. > If you need characters in a properties file outside the Latin-1 range > you need to use the \u.... notation to enter the codes for the > characters. > > If you don't want to type all that by hand, use the native2ascii tool > (comes with the JDK) to convert some non Latin-1 file (e.g. UTF-8) to > Latin-1 with \u escapes. > > I suggest you add the conversion via native2ascii to your build > system, so the conversion is automated whenever you change the input > file. > > /Thomas > You are indeed correct about the documentation. I found it and it says what you say. ** gets on soapbox ** I just had a hard time bringing myself to believe that Java I18N would be so limited when it has all the resources of Taligent folded into it. Everyone always pushes how web-enabled Java is and how great it is with I18N/L10N. I was thinking there had to be some update or better way of doing something that is integral to the _world_ wide web and I18N. ** off soapbox ** == 2 of 2 == Date: Thurs, Nov 18 2004 2:18 pm From: Todd Carnes <[EMAIL PROTECTED]> I work with Japanese text occassionally & I would just like add that you might want to be careful about cutting & pasting what you get from Babel and then "assuming" it's unicode. Most likely it's not. There are several different encodings for Japanese & if I were forced to choose which I thought was most prevelant, I'd have to say that Unicode is the least used encoding scheme. I think you're much more likely to run into Shift-JIS or EUC-JP encoding, at least that's what I usually see on the web. ========================================================================== TOPIC: applet problem http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/77127616376e3ddd ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 11:03 am From: Lam <[EMAIL PROTECTED]> hi, i have an applet problem i have created an applet which his comportment is correct on Mozilla, IE under Linux or windows with Sun VM, but incorrect with Microsoft VM does anybody know if it is possible de specify which VM must be install on the client ? like in applet tag ? thanks for any help -- Lam ========================================================================== TOPIC: Which way is more efficient - comparing strings of different letter casing http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3acc767a96f24a10 ========================================================================== == 1 of 6 == Date: Thurs, Nov 18 2004 11:15 am From: kaeli <[EMAIL PROTECTED]> In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] enlightened us with... > kaeli <[EMAIL PROTECTED]> wrote: > > If I have a string and I don't know the letter case, and I wish to compare > > it > > to a known string of known case, which of these methods is more efficient? > > Using equalsIgnoreCase is the right way to do this. I can almost > guarantee it's more efficient, just based on simple logic -- if it > weren't, then Sun would replace the current implementation with your > code instead. The key point, though, is not that it's measured to be > efficient, but simply that it's the right abstraction. > > Now I'm wondering... What are some valid uses for compareTo and compareToIgnoreCase, then? My first thought was sorting, but there has to be a more efficient way to sort than that. -- -- ~kaeli~ God was my co-pilot... but then we crashed in the mountains and I had to eat him. http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace == 2 of 6 == Date: Thurs, Nov 18 2004 11:12 am From: kaeli <[EMAIL PROTECTED]> In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] enlightened us with... > kaeli <[EMAIL PROTECTED]> wrote: > > If I have a string and I don't know the letter case, and I wish to compare > > it > > to a known string of known case, which of these methods is more efficient? > > Using equalsIgnoreCase is the right way to do this. I feel like a moron. I didn't know about that method. One would think I could read the API docs. Really. *embarrassed grin* -- -- ~kaeli~ God was my co-pilot... but then we crashed in the mountains and I had to eat him. http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace == 3 of 6 == Date: Thurs, Nov 18 2004 11:44 am From: Chris Smith <[EMAIL PROTECTED]> kaeli <[EMAIL PROTECTED]> wrote: > Now I'm wondering... > What are some valid uses for compareTo and compareToIgnoreCase, then? My > first thought was sorting, but there has to be a more efficient way to sort > than that. Sorting is the main one. Of course, the sort algorithm is provided by Collections.sort and Arrays.sort; but the comparison is pluggable. String implements the Comparable interface, so the compareTo method actually defines the default ordering of String objects if you don't specify a Comparator to the sort. compareToIgnoreCase, on the other hand, would need to be specified in an explicit Comparator as follows: Collections.sort(myStrings, new Comparator() { public int compare(Object a, Object b) { return ((String) a).compareToIgnoreCase((String) b); } }); -- www.designacourse.com The Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation == 4 of 6 == Date: Thurs, Nov 18 2004 11:49 am From: Chris Smith <[EMAIL PROTECTED]> Chris Smith <[EMAIL PROTECTED]> wrote: > Sorting is the main one. [...] Let me also mention that these methods, along with Comparable and Comparator can be used in other ways that relate to ordering of objects but are not sorting per se. For example, many data structures implement certain ordering constraints that can be checked via compareTo methods, but stop short of full-fledged sorting. A heap tree used to implement a priority queue, for example, would fit this description. -- www.designacourse.com The Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation == 5 of 6 == Date: Thurs, Nov 18 2004 12:25 pm From: kaeli <[EMAIL PROTECTED]> In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] enlightened us with... > Chris Smith <[EMAIL PROTECTED]> wrote: > > Sorting is the main one. [...] > > Let me also mention that these methods, along with Comparable and > Comparator can be used in other ways that relate to ordering of objects > but are not sorting per se. For example, many data structures implement > certain ordering constraints that can be checked via compareTo methods, > but stop short of full-fledged sorting. A heap tree used to implement a > priority queue, for example, would fit this description. > > Thanks for the info. Can you point me to more resources about the heap tree / priority queue? I currently have an application that deals with a queue for jobs and, having coded it fresh and new to java from C, I coded it as vectors and do all kinds of interesting things to try to figure out which job has priority... ;) -- -- ~kaeli~ Acupuncture is a jab well done. http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace == 6 of 6 == Date: Thurs, Nov 18 2004 1:44 pm From: Chris Smith <[EMAIL PROTECTED]> kaeli <[EMAIL PROTECTED]> wrote: > Thanks for the info. > > Can you point me to more resources about the heap tree / priority queue? I > currently have an application that deals with a queue for jobs and, having > coded it fresh and new to java from C, I coded it as vectors and do all kinds > of interesting things to try to figure out which job has priority... ;) Any data structures book should discuss this. Here are some online URLs that look good to get you started: http://www2.toki.or.id/book/AlgDesignManual/BOOK/BOOK3/NODE130.HTM http://ciips.ee.uwa.edu.au/~morris/Year2/PLDS210/heaps.html http://www.csua.berkeley.edu/~ranga/school/cs161/ -- www.designacourse.com The Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation ========================================================================== TOPIC: Class and interface loading order http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dc413d1e05db6fe ========================================================================== == 1 of 2 == Date: Thurs, Nov 18 2004 11:18 am From: [EMAIL PROTECTED] (Fernando) In resume, I have a factory class that creates/instantiates a family of classes, like in this example: public class Test{ public static void main(String args[]){ TestInterface t = Factory.getInstance(0); t.f(); } } class Factory{ public static TestInterface getInstance(int type){ System.out.println("Executed Factory.getInstance()"); switch(type){ case 0: return new TestInterfaceImpl0(); case 1: return new TestInterfaceImpl1(); default: return new TestInterfaceImpl2(); } } } abstract class TestInterface{ public abstract void f(); } class TestInterfaceImpl0 extends TestInterface{ public void f(){ System.out.println("Executed TestInterfaceImpl0.f()"); } } class TestInterfaceImpl1 extends TestInterface{ public void f(){ System.out.println("Executed TestInterfaceImpl1.f()"); } } class TestInterfaceImpl2 extends TestInterface{ public void f(){ System.out.println("Executed TestInterfaceImpl2.f()"); } } When I run Test class using -verbose:class option I got this output: [Loaded Test] [Loaded Factory] [Loaded TestInterface] [Loaded TestInterfaceImpl0] [Loaded TestInterfaceImpl1] [Loaded TestInterfaceImpl2] Executed Factory.getInstance() Executed TestInterfaceImpl0.f() So, what we see here is that JVM loads ALL classes referenced from Factory.getInstance() (TestInterfaceImpl0, TestInterfaceImpl1 and TestInterfaceImpl2) before it is executed. Now, my question. If I change the abstract class TestInterface into an interface, the loading order is completely different. See: public class Test{ public static void main(String args[]){ TestInterface t = Factory.getInstance(0); t.f(); } } class Factory{ public static TestInterface getInstance(int type){ System.out.println("Executed Factory.getInstance()"); switch(type){ case 0: return new TestInterfaceImpl0(); case 1: return new TestInterfaceImpl1(); default: return new TestInterfaceImpl2(); } } } interface TestInterface{ public void f(); } class TestInterfaceImpl0 implements TestInterface{ public void f(){ System.out.println("Executed TestInterfaceImpl0.f()"); } } class TestInterfaceImpl1 implements TestInterface{ public void f(){ System.out.println("Executed TestInterfaceImpl1.f()"); } } class TestInterfaceImpl2 implements TestInterface{ public void f(){ System.out.println("Executed TestInterfaceImpl2.f()"); } } When I run Test class using -verbose:class option I got this output: [Loaded Test] [Loaded Factory] [Loaded TestInterface] Executed Factory.getInstance() [Loaded TestInterfaceImpl0] Executed TestInterfaceImpl0.f() This time, ONLY TestInterfaceImpl0 is loaded and its loading is postponed until it is needed (Factory.getInstance() before the loading). Does anyone now why this happens? Thanks a lot. Regards, Fernando. == 2 of 2 == Date: Thurs, Nov 18 2004 2:05 pm From: "bilbo" <[EMAIL PROTECTED]> Fernando wrote: > In resume, I have a factory class that creates/instantiates a family > of classes, like in this example: [snipped code where TestInterface is an abstract class] > > When I run Test class using -verbose:class option I got this output: > > [Loaded Test] > [Loaded Factory] > [Loaded TestInterface] > [Loaded TestInterfaceImpl0] > [Loaded TestInterfaceImpl1] > [Loaded TestInterfaceImpl2] > Executed Factory.getInstance() > Executed TestInterfaceImpl0.f() > > So, what we see here is that JVM loads ALL classes referenced from > Factory.getInstance() (TestInterfaceImpl0, TestInterfaceImpl1 and > TestInterfaceImpl2) before it is executed. > > Now, my question. If I change the abstract class TestInterface into an > interface, the loading order is completely different. See: [snipped code where TestInterface is an interface] > When I run Test class using -verbose:class option I got this output: > > [Loaded Test] > [Loaded Factory] > [Loaded TestInterface] > Executed Factory.getInstance() > [Loaded TestInterfaceImpl0] > Executed TestInterfaceImpl0.f() > > This time, ONLY TestInterfaceImpl0 is loaded and its loading is > postponed until it is needed (Factory.getInstance() before the > loading). > > Does anyone now why this happens? > > Thanks a lot. >From my understanding of JLS (http://java.sun.com/docs/books/jls/index.html) chapter 12, both the behaviors you noticed above are allowed, so it's really just implementation dependent. I have no idea why the implementation does different things for your two examples, but they both exhibit standards compliant behavior. Specifially, check out JLS section 12.1.2: http://java.sun.com/docs/books/jls/second_edition/html/execution.doc.html#44459 It specifically explains that an implementation is free to be lazy and only load classes the first time they're actually used, or at the other extreme, recursively resolve all references as soon as a class is loaded, and specifically mentions that this may cause errors to occur at different times, or not at all, depending on the ClassLoader implementation. In your example the first program will die with an error if the TestInterfaceImpl1.class is not found at runtime, whereas the second example runs fine. Unfortunately both behaviors are allowed by the JLS. On the related issue of class initialization, the spec, section 12.4.1, is much more strict about when initialization occurs, and basically says a class can't be initialized until it is about to be used in some way. So in your example, if TestInterfaceImpl1 contained a static block, it would never be called since you never used TestInterfaceImpl1 in your program. ========================================================================== TOPIC: UnsatisfiedLinkError in Eclipse standalone SWT app http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e03dc0d087a5062a ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 1:01 pm From: Henry Law <[EMAIL PROTECTED]> Eclipse 3.0.0 under Windows XP. I have (as far as I can see) followed the instructions in the cheat sheet for "Standalone SWT Application" but I have the following error on running it: java.lang.UnsatisfiedLinkError: no swt-win32-3062 in java.library.path I have coded -Djava.library.path=${system:ECLIPSE_HOME}/plugins/org.eclipse.swt.${system:WS}_3.0.0/os/${system:OS}/${system:ARCH} in the "arguments" box (and various other variants of it including hard path names), and verified that C:\USR\eclipse\plugins\org.eclipse.swt.win32_3.0.0\os\win32\x86\swt-win32-3062.dll does actually exist in my system. I've also set ECLIPSE_HOME as an environment variable (just in case), without improving things. I've also Googled for the error and found only the advice to put in the -D parameter, but I have done that already. Can someone suggest somewhere else I might look for an error? -- Henry Law <>< Manchester, England ========================================================================== TOPIC: validating classpaths http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9ee9967e34de9e2c ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 1:15 pm From: [EMAIL PROTECTED] (John Coltrane) I there a tool I can use that will dump out the fully qualified jar filenames that are access by either an individual java file or group of files. I would like to be able to verify that java projects built on different systems are accessing the same jar files. It would be great if versions were included but I don't want to get greedy :)) thanks for the help jprok ========================================================================== TOPIC: Time conversion problem. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1726e3482ae3b094 ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 1:31 pm From: [EMAIL PROTECTED] (siliconsmiley) Carl <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > > Does the machine reside in the GMT time zone, or the East coast U.S by > any chance? Perhaps you need to adjust for your time zone offset. > > Carl. It was the time zone. I'm in the East Coast time zone in the U.S. Java seems to have assumed that from the settings on my PC. I did: tz = TimeZone.getTimeZone("GMT+0"); and it works great. Thanks for you help. ========================================================================== TOPIC: I wrote my own Java in BASIC ! ! ! http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/29ec22b23b7d5d6d ========================================================================== == 1 of 2 == Date: Thurs, Nov 18 2004 1:37 pm From: "Virgil Green" <[EMAIL PROTECTED]> "KiLVaiDeN" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > "Hans-Marc Olsen" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Java was too expensive for me, so I wrote my own Java in BASIC. > > I wrote my own BASIC in a HEX editor. So you are nothing to me. I wrote my own compiler and JVM by using a bar magnet on a string and swinging it very precisely over a mound of metal filings. - Virgil == 2 of 2 == Date: Thurs, Nov 18 2004 2:20 pm From: Todd Carnes <[EMAIL PROTECTED]> Hans-Marc Olsen wrote: > Java was too expensive for me, so I wrote my own Java in BASIC. Java is free. ========================================================================== TOPIC: Writing to Word documents http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/63e6214e752428a ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 1:44 pm From: [EMAIL PROTECTED] (Y2KYZFR1) [EMAIL PROTECTED] (Jonck van der Kogel) wrote in message news:<[EMAIL PROTECTED]>... > Hi everybody, > I have defined a Word template and set bookmarks at certain locations > in this document, to which I then want to write text gotten from a > database and save the file. In this way I could create standard > documents (for example an invoice) in an automated manner. > I have looked into the Jakarta POI project > (http://jakarta.apache.org/poi/index.html), but this project is mostly > aimed at Excel, Word support is still in its infancy. > Another solution that I've found > (http://www.must.de/en/default.html?../Javactpe.htm) seems to work > very well, but is Windows only. > Also there are a few commercial solutions, but these cost several > thousand dollars, which I can't afford. > > I figure such an automated creation of Word documents is probably > being done by a lot of people, so therefore I was wondering, does > anyone know of a (affordable) way to achieve what I described in a > platform independent manner? > > Thanks very much, Jonck write to an RTF format, that will open right up in word, or html, either one can be imported into word by clueless users with no problems. RTF is probably the best becuase its extension is mapped to word by default ========================================================================== TOPIC: loading a class whose bytecode comes in a byte[] http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4e991c30dd027000 ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 1:55 pm From: Luca Rosellini <[EMAIL PROTECTED]> On Thu, 18 Nov 2004 08:57:54 -0500 "John C. Bollinger" <[EMAIL PROTECTED]> wrote: JCB> If that doesn't solve the problem then come back JCB> with the full stack trace of your exception and complete code for the JCB> ClassLoader and attempted class instantiation. If there is Java code JCB> for the class being transferred and its dependencies then that might be JCB> helpful too. Thanks for the answer John, I tried to follow your suggestions, but unfortunately still doesn't want to work. Before pasting the stacktrace I'll briefly explain the structure of the program to let you understand better: there's a thread server that listens for incoming datagrams, when a new message arrives a new thread is spawned to handle it. The incoming message contains an instance of class SubscriptionParameters which implements the Externalizable interface. Filter is an interface known to both node A and B (sender and receiver) in package "filters". The class I want to load on the receiver is an implementation of Filter (implemented by node A, the sender): //SubscriptionParameters.java package datatypes; class SubscriptionParameters implements Externalizable { ... private byte[] evFilter; Filter filterInstance; ... public void writeExternal(java.io.ObjectOutput objectOutput) throws java.io.IOException { ... // the name of the class serialized by sender is something like // filter.TempFilter, filter is a package present on bot node A and B objectOutput.writeObject( filterInstance.getClass().getName() ); objectOutput.writeObject( evFilter ); objectOutput.writeObject( filterInstance ); } public void readExternal(java.io.ObjectInput objectInput) throws java.io.IOException, java.lang.ClassNotFoundException { ... String className = (String)objectInput.readObject(); evFilter = (byte[])objectInput.readObject(); try { FilterClassLoader fcl = new FilterClassLoader( this.getClass().getClassLoader(), evFilter); Class loadedFilter = fcl.loadClass( className ); /* the exception is raised here when trying to deserialize the instance * of the class that should be already loaded */ line83: filterInstance = (Filter)objectInput.readObject(); } } } This is the inherited ClassLoader: //FilterClassLoader.java package filters; public class FilterClassLoader extends ClassLoader { private byte[] classData; public FilterClassLoader(ClassLoader parent, byte[] data) { super(parent); classData = data; } public Class findClass(String className) { return defineClass(className, classData, 0, classData.length); } } and here is the stacktrace: java.lang.ClassNotFoundException: filters.TempFilter at java.net.URLClassLoader$1.run(URLClassLoader.java:199) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:187) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:219) at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:558) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1513) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324) at datatypes.SubscriptionParameters.readExternal(SubscriptionParameters.java:83) at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1686) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1644) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324) at transport.PublishSubscribeDatagramSocket.receive(PublishSubscribeDatagramSocket.java:85) at nodes.DispatcherServerThread.run(DispatcherServerThread.java:79) I tryied to put a System.out.println(...) in my findClass(...) to check if it is properly called, and it is. Hope this helps you to point me what I am doing wrong. Best Luca ========================================================================== TOPIC: Is "String s = "abc";" equal to "String s = new String("abc");"? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/57b8aacdcf136f3f ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 2:04 pm From: "Mike Schilling" <[EMAIL PROTECTED]> "Michael Borgwardt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Bruce Sam wrote: > >> In my opinion,"String s = "abc";" has only created a reference s not a >> object."String s= new String("abc");" has created a new object and its >> reference is s.Is it right? > > Not really. Both declare a reference, and while the first doesn't > explicitly *create* an object at runtime, there still *is* an Object. > It's part of the constant pool of the class and created when the > class is loaded. The second creates two objects, since the constant String "abc" and the results of "new String()" must be distinct. ========================================================================== TOPIC: implementing comparable http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9f2d220f347ddff4 ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 2:03 pm From: steve <[EMAIL PROTECTED]> On Wed, 17 Nov 2004 10:33:52 +0800, Chris Smith wrote (in article <[EMAIL PROTECTED]>): > Steve, > > I'm afraid your question is somewhat unclear. I'm not quite sure where > you're starting from. Can you please describe in detail exactly what's > in the vector you mention, and how you intend to identify the selected > "column" of data within the elements? > > one too many actually. it all stems from the fact that i needed to sort a vector of items . The vector is used to display an on screen table. the table has a number of columns. ( which could contain any basic java type -int,string,date,float- but not complex user defined objects) The user selects which column , they want to sort on. the selection is via , some radio buttons, but could just as easily be called from a double click on the column header the 'comparable' takes 2 "objects" , which in this case would be 2 vectors objects containing a collection of strings. basically you need a vector of vectors , not a vector of strings. ( if you want to expand the comparable, you need to maintain type safety, and therefore cannot assume you are dealing with strings) the (OLD) basic code that loads the vector from a database is shown. java.sql.ResultSetMetaData rsmd = rset.getMetaData(); int ColumnCount = rsmd.getColumnCount(); newmapping_list.removeAllElements(); // empty the supplier list while (rset.next()) { String[] record1 = new String[ColumnCount]; for (int i = 0; i < record1.length; i++) { record1[i] = (String) rset.getString(i + 1); // COPY THE DATA TO A LOCAL ARRAY OF THE RIGHT SIZE } loop++; newmapping_list.addElement(record1); } whilst this is excellent for on screen display of items , but it is complete shite for loading a vector of items , that require sorting. ( it will never work correctly) I have therefore changed it to: newmapping_list.removeAllElements(); // empty the supplier list while (rset.next()) { Vector record1 = new Vector(); // new String[ColumnCount]; for (int i = 0; i < ColumnCount; i++) { // record1[i] = (Object) rset.getObject(i + 1); // COPY THE DATA TO A LOCAL ARRAY OF THE RIGHT SIZE record1.add((String) rset.getString(i + 1)); } loop++; newmapping_list.addElement(record1); } now i can implement my comparable as: public int compare(Object one, Object two) { Vector actualRow1 = (Vector) one; Vector actualRow2 = (Vector) two; Object ColItem1 = actualRow1.get(colIndex); Object ColItem2 = actualRow2.get(colIndex); ........ compare routines based on object types follow. Which now gives me access to the "actual" col, objects, simply by passing an index.( from the radio buttons or the double click on the col header) whereas before I was trying to convert an array of strings back to a vector, because i am working on a single comparator for all my tables, same as i have a 'single' table model. Basically i was fumbling about in the comparator , when the problem was else where. ( the routine that was getting the actual data from the database) I just need to change all my "get string routines" to "get vector routines", which i had originally written , to make the overriding of the java table objects easier. that said, i am very surprised at the speed, this can sort several hundreds of items. steve ========================================================================== TOPIC: Search for byte pattern in a binary file. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc671002cbe38f70 ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 2:27 pm From: [EMAIL PROTECTED] (Tim Jowers) Thomas Weidenfeller <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Ryan Tan via JavaKB.com wrote: > > Hi there, does anyone have a quick way to search for a byte pattern in a > > binary file? > > Look at (Google for) algorithms like Boyer-Moore, Knuth-Morris-Pratt or > Rabin-Karp. > > > /Thomas Which "quick" are you talking about? String.split() using a regular expression of what you want to match as StringTokenizer only works on char delims I think. Or maybe something like this: http://javaalmanac.com/egs/java.util.regex/Tokenize.html. Or did you mean quick performance? Seems to me that the algorithm can be optimised by skipping compares. On what unit? For instance, if your first byte set is "abbacdedf" then you could measure from statistical sampling (or measures from a book) that "b,c,d, or f" are much less common than "a or e", then you can cut the sample set up by matching on those letter. E.g. start in the middle. If the set of 8 characters does not contain a "b" or an "f", then recurse each side taking blocks of 8 characters - cutting your processing time down by 4x or more. Thus, I project your division is determined by the data and that an optimal division would account for pattern frequencies in the match set and the input set. Of course this algorithm can be reversed to use patterns in the incoming data versus the match set. OTOH, you could do a string tokenization on the string to be matched and just get a faster machine. :-) What did you come up with? TimJowers ========================================================================== TOPIC: Sun's Java Forums - When Will They Be Back? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ba8f8003d1842a83 ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 2:14 pm From: "Rhino" <[EMAIL PROTECTED]> I don't go to the Java Forums at Sun too often but they have always been there when I went. Today, I have gone to these forums several times over a span of several hours and they have been offline for service. No matter which link I use to get to the Forums, I get redirected to this page: http://developer.java.sun.com/maintenance.html which says, in part, "We are in the process of upgrading portions of the Sun Developer Network". Unfortunately, they don't give any indication of when this upgrade began or when it is expected to end. At first, I thought they were only down a few minutes for some routine or emergency maintenance but since it is now several hours since I first tried to access these forums, I am wondering if they are expected to be down for a much longer period, like weeks. Does anyone know when they are expected to be back? I am trying to do some J2ME development but there seem to be very few active forums in this area so I was hoping that the Sun forums would have some active J2ME forums. They're not much good to me if they are going to be gone for days or weeks though. -- Rhino --- rhino1 AT sympatico DOT ca "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies." - C.A.R. Hoare ========================================================================== TOPIC: Version 1.3.1 Versus 1.4.2_04 http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/65e179ef76a09f65 ========================================================================== == 1 of 2 == Date: Thurs, Nov 18 2004 3:08 pm From: [EMAIL PROTECTED] (Kevin Simonson) Michael Borgwardt <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... => I think both machines I ran that program on were Linux machines. => How do I go about finding out if the "classpath" variable is set, and => how to change it if it is? = =echo $CLASSPATH = =should tell you the content of the variable. As for where it's set, there =are many places, the most likely being the files /etc/profile, /etc/profile.local =and .bashrc (since you seem to be using bash) in your home directory. As you can see below, I tried "echo $CLASSPATH" on the same ma- chine I was having the problem on, and <CLASSPATH> didn't appear to have a value. I took a look in "/etc/profile" and ".bashrc", to no avail. Note that my system doesn't appear to have a "/etc/profile.local" file. Any more ideas as to why I can't declare an object of class <Bug> immediately after compiling "Bug.java"? ---thanks, Kevin Simonson "You'll never get to heaven, or even to LA, if you don't believe there's a way." from _Why Not_ ---------------------------------------------------------------------- [EMAIL PROTECTED] Rid3]$ hostname star [EMAIL PROTECTED] Rid3]$ echo $CLASSPATH [EMAIL PROTECTED] Rid3]$ ls -dF /etc/profile* /etc/profile /etc/profile.d/ [EMAIL PROTECTED] Rid3]$ grep -i classp /etc/profile [EMAIL PROTECTED] Rid3]$ grep -i classp ~/.bashrc [EMAIL PROTECTED] Rid3]$ == 2 of 2 == Date: Thurs, Nov 18 2004 3:11 pm From: [EMAIL PROTECTED] (Kevin Simonson) [EMAIL PROTECTED] (John) wrote in message news:<[EMAIL PROTECTED]>... =You might try enclosing (new Bug( 7)).bugSquared() in parentheses: = =System.out.println = ( "(new Bug( 7)).bugSquared() == " + ((new Bug( 7)).bugSquared()) + ='.'); = =Also, the parenthese around (new Bug( 7)) before .bugSquared() =shouldn't be necessary. John, I tried enclosing "(new Bug( 7)).bugSquared()" in parenthe- ses, both with and without the parentheses around "(new Bug( 7))", and neither one let my code compile. Any other ideas? ---thanks, Kevin Simonson "You'll never get to heaven, or even to LA, if you don't believe there's a way." from _Why Not_ ---------------------------------------------------------------------- [EMAIL PROTECTED] Rid3]$ hostname star [EMAIL PROTECTED] Rid3]$ cat Bug.java public class Bug { int bug; public Bug ( int bg) { bug = bg; } public int bugSquared () { return bug * bug; } } [EMAIL PROTECTED] Rid3]$ cat BugDriver.java public class BugDriver { public static void main ( String[] arguments) { System.out.println ( "(new Bug( 7)).bugSquared() == " + ((new Bug( 7)).bugSquared()) + '.'); } } [EMAIL PROTECTED] Rid3]$ cat BugDriver2.java public class BugDriver2 { public static void main ( String[] arguments) { System.out.println ( "(new Bug( 7).bugSquared()) == " + (new Bug( 7).bugSquared()) + '.'); } } [EMAIL PROTECTED] Rid3]$ javac Bug.java [EMAIL PROTECTED] Rid3]$ javac BugDriver.java BugDriver.java: In class `BugDriver': BugDriver.java: In method `BugDriver.main(java.lang.String[])': BugDriver.java:6: Class `Bug' not found in type declaration. ( "(new Bug( 7)).bugSquared() == " + ((new Bug( 7)).bugSquared()) + '.' ); ^ 1 error [EMAIL PROTECTED] Rid3]$ javac BugDriver2.java BugDriver2.java: In class `BugDriver2': BugDriver2.java: In method `BugDriver2.main(java.lang.String[])': BugDriver2.java:6: Class `Bug' not found in type declaration. ( "(new Bug( 7).bugSquared()) == " + (new Bug( 7).bugSquared()) + '.'); ^ 1 error [EMAIL PROTECTED] Rid3]$ tack:kvnsmnsn/Ncl_bash-2.05b$ ========================================================================== TOPIC: HTTPUnit not working against an https (SSL) site http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8d793f5e72fb7839 ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 3:11 pm From: [EMAIL PROTECTED] (samotto) I am not sure if I am using HTTPSUrlConnections or SSLSockets. How do I tell? We have a dev site and a production site. When I set the request to go to the dev site (with http:// in the url) everything works. When I change the request url to our prod site (with https://) I get the error. So do I need to change something else in my code to the the HTTPS stuff? Thanks for your time... Sam Bruno Grieder <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Sam wrote: > > I am trying to test a request/response from a https address and > > getting the error > > > > java.lang.RuntimeException: https support requires the Java Secure > > Sockets Extension. See http://java.sun.com/products/jsse > > > > I have the jdk version 1.4.2_05 which says the JSSE is now part of the > > jdk. > > > > I also have > > > > security.provider.2=com.sun.net.ssl.internal.ssl.Provider > > > > in my java.security file. > > > > What am I doing wrong? > > > > Thanks in advance > > > > Sam > > > Mhh... Strange. I am using the same version without any issue (on Linux) > and I confirm that (contrarily to 1.3) there is no set-up to do at all > to use the default Sun libraries. I have tried with the Apache > httpclient librairies with similar success. > > Are you sure you are actually using HTTPSUrlConnections or opening > SSLSockets when connecting? > > bruno ======================================================================= 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
