comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * why does ObjectInputStream constructor block reading a header - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7b8520ff9f293b96 * help with internationalization/localization - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b2947dc6ffc5f377 * Homework - Was Re: java programe help - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8fddd0a49ac12937 * why dont I get exception here(servlets) - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7ced949238f6fcd9 * Challenge: Triangles puzzle - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5e013ca5d7daa5f0 * MIDLet newbie questions - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4fe913f96a7b75ac * Deploying MIDlet via cable? - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/939c5a9412e6b4a8 * Developing MIDlet for PDAs and cell phones - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5d0109d66581670e * Stupid null pointer exception - 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aeeebd0bb6f11be3 * array comparison and sort - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4208721fbec39fc3 * Java Web Start and Directory Structure - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/84343be35a56594c * applet's call comportement - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc1d4563dc67060c ========================================================================== TOPIC: why does ObjectInputStream constructor block reading a header http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7b8520ff9f293b96 ========================================================================== == 1 of 2 == Date: Sat, Oct 30 2004 2:18 am From: Esmond Pitt <[EMAIL PROTECTED]> kartik wrote: > The ObjectInputStream constructor blocks till it reads a header from > the underlying input stream. This can cause deadlocks when you have a > pair of object streams communicating over sockets (it has happened to > me). Does anybody know why it may have been coded this way instead of > reading the header on the first call to readObject()? No but you can avoid the deadlock by creating the ObjectOutputStream first and flushing it, then creating the ObjectInputStream. == 2 of 2 == Date: Sat, Oct 30 2004 2:37 am From: "Tony Morris" <[EMAIL PROTECTED]> "kartik" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The ObjectInputStream constructor blocks till it reads a header from > the underlying input stream. This can cause deadlocks when you have a > pair of object streams communicating over sockets (it has happened to > me). Does anybody know why it may have been coded this way instead of > reading the header on the first call to readObject()? > > -kartik Yes - they have been written in accordance with specification and the specification is the correct way of solving the problem. The problem you have is attempting asynchronous I/O in the same thread. This is just not possible. -- Tony Morris http://xdweb.net/~dibblego/ ========================================================================== TOPIC: help with internationalization/localization http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b2947dc6ffc5f377 ========================================================================== == 1 of 3 == Date: Sat, Oct 30 2004 4:11 am From: "Boudewijn Dijkstra" <[EMAIL PROTECTED]> "La?ie Techie" <[EMAIL PROTECTED]> schreef in bericht news:1099120423./[EMAIL PROTECTED] > On Sat, 30 Oct 2004 05:09:27 +0000, Praveen wrote: > >> 3. renamed the file to the resource bundle Message_zh_TW.properties with >> one entry >> Database = ??? > > You should escape the unicode characters. Not all of them, just the chinese ones. == 2 of 3 == Date: Sat, Oct 30 2004 8:50 am From: Praveen <[EMAIL PROTECTED]> How do I escape the unicode characters? The entry is like e.g Database = \123\456\789\123\456\789\123\456\789 Do I need to convert them using native2ascii & get the entry like \u2034 etc? Boudewijn Dijkstra wrote: > "La?ie Techie" <[EMAIL PROTECTED]> schreef in bericht > news:1099120423./[EMAIL PROTECTED] > >>On Sat, 30 Oct 2004 05:09:27 +0000, Praveen wrote: >> >> >>>3. renamed the file to the resource bundle Message_zh_TW.properties with >>>one entry >>>Database = ??? >> >>You should escape the unicode characters. > > > Not all of them, just the chinese ones. > > == 3 of 3 == Date: Sat, Oct 30 2004 8:53 am From: Praveen <[EMAIL PROTECTED]> Lāʻie Techie wrote: > On Sat, 30 Oct 2004 05:09:27 +0000, Praveen wrote: > > >>3. renamed the file to the resource bundle Message_zh_TW.properties with >>one entry >>Database = 資料庫 > > > You should escape the unicode characters. How do I escape the characters? Can you please give me an example. > > >>4. But once I run the test by creating a new locale("zh", "TW") & try to >>get the string "Database", it prints ??? > > > Prints where and how? A question mark generally states that particular > character is not defined in the current font and/or codepage. On the Browser. After the application reads it from the MessageBundle. > > >>If I read this file from a browser directly file://c:/<file name> it >>displays the character correctly. > > > Read it how? In a browser? In a UTF-8 aware text editor? "Type"ing it > on the command prompt? Again on the browser. If you open a browser & point it to the file with special character & if it displays that means you have the fonts. > > HTH, > La'ie Techie > ========================================================================== TOPIC: Homework - Was Re: java programe help http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8fddd0a49ac12937 ========================================================================== == 1 of 1 == Date: Sat, Oct 30 2004 4:55 am From: Alex Hunsley <[EMAIL PROTECTED]> Yogo wrote: > "Alex Hunsley" wrote: > >>I think it's you who should calm down a bit and not imply the regulars >>here of replying to posters as if they are "murderers and rapists". You >>owe people here an apology for that implication. >> > > > I don't owe an apology to anyone for this. If you can't read / think > properly that's not my problem... True, but if in fact the problem is that you make wildly inappropriate comments, that *is* your problem. >>>>>I should blame the original poster because I'm annoyed by YOUR reply? >>>>>:-) >>>> >>>>Yes. >>> >>> >>>Nope. >> >>How convenient for you - to snip the rest of my paragraph and make it look >>like "Yes" is all I wrote. >> > > > Yeah, I have to agree, it was pretty convenient :-) You've reached my killfile. Well done! I do hope you get a clue sometime. <kerplonk> ========================================================================== TOPIC: why dont I get exception here(servlets) http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7ced949238f6fcd9 ========================================================================== == 1 of 2 == Date: Sat, Oct 30 2004 5:24 am From: "Madhur Ahuja" <[EMAIL PROTECTED]> According to javadocs in HttpServletReponse: sendRedirect If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to. I want to know, how can I commit the reponse. I tried flushing the buffer, but still I didnt get IllegalStateException. Running Tomcat 4. Here is the code: <html> <head> <title>servlet</title> </head> <body> <% if (request.getParameter("name")==null) { out.println("<h1>hello world</h1>"); out.flush(); response.setHeader("madhur","ahuja"); response.flushBuffer(); response.sendRedirect("/login.jsp"); } else {%> <h1>hello <%=request.getParameter("name") %> </h1> <% } %> </body> </html> -- Madhur Ahuja [madhur<underscore>ahuja<at>yahoo<dot>com] Homepage http://madhur.netfirms.com == 2 of 2 == Date: Sat, Oct 30 2004 5:59 am From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> If you just want to generate an IllegalStateException, you could probably either set a small buffer size with a page directive or write out more that the current buffer size (4 or 8kb) before using the response.sendRedirect(). There's probably a page directive to disable page buffering that would "help", too. The directive is something like: <%@ page buffer=8kb %> ========================================================================== TOPIC: Challenge: Triangles puzzle http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5e013ca5d7daa5f0 ========================================================================== == 1 of 1 == Date: Sat, Oct 30 2004 5:17 am From: Gareth McCaughan <[EMAIL PROTECTED]> Dirk Thierbach wrote: [I said:] >> Yes. In particular, the *very* short solutions all (1) used >> assignments within the program as input (though they didn't >> count those assignments as part of the code), > > No, at least one short solution did count those assignments (3 lines > of assignments out of 6 total lines of code). I beg your pardon; I misremembered. > You could replace those 3 lines by 1 line to read the contents of a file, > 1 line to parse it and to call the algorithm, 1 line to calculate the > missing part of the input definition, and 1 line to print the result. > Maybe an additional line to get the filename from the commandline arguments. > So instead of 3, you have 4-5 lines. I didn't bother, because then you have > to edit 2 files instead of 1 for testing. Sure. >> (2) used numbers to represent points, which enables various minor >> algorithmic simplifications. > > Nope. Anything that's comparable will do for the simple solution, > and with two additional lines, you can use anything that only admits equality. I'm not sure how we're in disagreement here... > If you just want the number of solutions, and not the solutions themselves > without "duplicates" by permutation, then you can do even without that > (just divide the length of the list of solutions by 6). Indeed. (Though you may, in some implementations, need a little extra code to avoid repeated points.) > BTW, one more important difference is that some algorithms just counted, > while some actually computed all solutions. Some algorithms restricted > themselves to two "fans" of lines, while some allowed an arbitrary > geometry. And so on, and so on. Indeed. The solution that was a 3-character program in J (or whatever it was) was particularly notable in this respect :-). (I get the impression that you think I think it was cheating to avoid using a separate file for the data. I don't.) -- Gareth McCaughan .sig under construc ========================================================================== TOPIC: MIDLet newbie questions http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4fe913f96a7b75ac ========================================================================== == 1 of 1 == Date: Fri, Oct 29 2004 11:33 am From: "Darryl L. Pierce" <[EMAIL PROTECTED]> Rhino wrote: > I've been toying with the idea of writing some MIDlets for my PDA for > quite a while. I think I'm just about ready to give it a try but I need to > get some basic questions out of the way first. > > I started by looking at Darryl Pierce's MIDlet FAQ at > http://bellsouthpwp.net/m/c/mcpierce/j2mefaq.html. I'm afraid that some > parts of it are a bit over my head Sorry about that. I want the FAQ to be easy to read, but I guess I personally get too technical at times. If you can give me particulars I can try to word it a bit better. <snip> > I'm getting a bit confused about everything I need to have in place before > I can write some code. <snip> > > Darryl's FAQ says I need: > - at least a JDK 1.3 (or higher); I have JDK 1.5 beta2 > - the reference iimplementation for the targeted profile; I downloaded > MIDP-2.0 because that is what my PDA runs > - the reference implementation for the targeted configuration; I > downloaded CLDC-1.1 because that is what my PDA runs > - Ant (I already had Ant 1.6.1 on my system) <snip> > I assume that the above items will be sufficient to develop code, once I > get it set up properly. However, I'm not sure what I need to *do* with the > CLDC and the MIDP reference implementations. I wrote that part a long time ago, when I thought downloading the Wireless Toolkit and integrating it into a build environment was too much work. Now, since I use Eclipse, I've found that integrating Eclipse, the EclipseME plugin and Sun's Wireless Toolkit I have a much better environment than I had before. > I created a MIDlet project in Eclipse, my development IDE, and created a > class to hold the HelloWorld code that Darryl gives in the FAQ. However, > none of the imports works, including Command, CommandListener, Display, > Displayable, Form and MIDlet (all prefixed by 'java.microedition.lcdue.'). Did you build the CLDC and MIDP reference implementations? And, did you include the JAR files they produce in your bootclasspath reference when building? > All of these classes are in the MIDP zip file. To what destination should > I unzip the files in the zip file? Also, to what destination should I > unzip the CLDC zip file? Do I need to do anything beyond unzipping these > zip files, such as compiling something? You don't unzip them. They are included in your bootclasspath command line for javac. > Is it a good or bad idea to do my development in Eclipse (2.1.3)? I'm not > sure if it would be better to keep my Midlet development activities > separate from Eclipse or not. If I am better off to avoid Eclipse, how > should I do my development? (I am not afraid of using the command line if > that is better.) Your best best is to get Eclipse 3.x and EclipseME and Sun's Wireless Toolkit 2.x. This is a complete environment for MIDP development. <snip> -- /** * @author Darryl L. Pierce <[EMAIL PROTECTED]> * @see The Infobahn Offramp <http://mcpierce.multiply.com> * @quote "Lobby, lobby, lobby, lobby, lobby, lobby..." - Adrian Monk */ ========================================================================== TOPIC: Deploying MIDlet via cable? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/939c5a9412e6b4a8 ========================================================================== == 1 of 3 == Date: Fri, Oct 29 2004 11:28 am From: "Darryl L. Pierce" <[EMAIL PROTECTED]> Rhino wrote: > I am a MIDlet newbie but I've done a fair bit of J2SE development. > > I would like to understand the deployment process for midlets a bit > better. I have downloaded the Wireless Toolkit (2.2) and would like to > install some of the demo applications on my Tungsten E PDA just to > practice the process of installing an application. Unfortunately I'm not > very clear on what I have to do. > > The J2ME FAQ at > http://bellsouthpwp.net/m/c/mcpierce/j2mefaq.html#provisioning seems vague > on the process. It's vague because there's no single way to deploy a MIDlet suite to a device. It's all dependant on the device itself. Most mobiles allow you to deploy via OTA using the WAP browser on the handset. Some devices (such as my Motorola V400) let you install via a USB/serial/irDA connection and special software. Still others (like the Siemens S55 or Nokia 36xx series) let you provision via Bluetooth. The MIDP is specifically unclear on the hows since that is something the OEM has to determine for themselves. For you, you'd be best served checking with Palm's website. Unfortunately, I'm personally unfamiliar with the Tungstens, which is why the FAQ has little to no specific information on that handset. If you figure out how to provision to that handset, I'd appreciate you sending me the details and I'll give you credit in the FAQ for the answer. <snip> > Also, I have one terminology question that is relevant to this issue. I > keep seeing the term "MIDlet suite" in the FAQ but I can't find a > definition of that term. Is it the JAD and the JAR files for the > application? Or both of those plus the MANIFEST.MF file? Or something else > altogether? The MIDlet suite is the JAR file. It's referred to as a suite since it can contain more than a single MIDlet. -- /** * @author Darryl L. Pierce <[EMAIL PROTECTED]> * @see The Infobahn Offramp <http://mcpierce.multiply.com> * @quote "Lobby, lobby, lobby, lobby, lobby, lobby..." - Adrian Monk */ == 2 of 3 == Date: Sat, Oct 30 2004 6:06 am From: "Rhino" <[EMAIL PROTECTED]> "Darryl L. Pierce" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Rhino wrote: > > > I am a MIDlet newbie but I've done a fair bit of J2SE development. > > > > I would like to understand the deployment process for midlets a bit > > better. I have downloaded the Wireless Toolkit (2.2) and would like to > > install some of the demo applications on my Tungsten E PDA just to > > practice the process of installing an application. Unfortunately I'm not > > very clear on what I have to do. > > > > The J2ME FAQ at > > http://bellsouthpwp.net/m/c/mcpierce/j2mefaq.html#provisioning seems vague > > on the process. > > It's vague because there's no single way to deploy a MIDlet suite to a > device. It's all dependant on the device itself. Most mobiles allow you to > deploy via OTA using the WAP browser on the handset. Some devices (such as > my Motorola V400) let you install via a USB/serial/irDA connection and > special software. Still others (like the Siemens S55 or Nokia 36xx series) > let you provision via Bluetooth. The MIDP is specifically unclear on the > hows since that is something the OEM has to determine for themselves. > Fair enough. I hope I didn't sound critical about the FAQ; it's actually quite helpful. I also understand now why it couldn't be more precise on the exact process(es) involved in provisioning. > For you, you'd be best served checking with Palm's website. Unfortunately, > I'm personally unfamiliar with the Tungstens, which is why the FAQ has > little to no specific information on that handset. If you figure out how to > provision to that handset, I'd appreciate you sending me the details and > I'll give you credit in the FAQ for the answer. > I'll see if the folks at Palm can help me out with that. I'll let you know what I find out. > <snip> > > > Also, I have one terminology question that is relevant to this issue. I > > keep seeing the term "MIDlet suite" in the FAQ but I can't find a > > definition of that term. Is it the JAD and the JAR files for the > > application? Or both of those plus the MANIFEST.MF file? Or something else > > altogether? > > The MIDlet suite is the JAR file. It's referred to as a suite since it can > contain more than a single MIDlet. > I'm glad I asked! From the context in the FAQ, I got the impression that it was *at least* the JAR *and* the JAD and possibly other things too. So am I right in understanding that ONLY the JAR has to be deployed and that the JAD doesn't get deployed? If so, why create the JAD in the first place? Rhino == 3 of 3 == Date: Sat, Oct 30 2004 6:10 am From: "Darryl L. Pierce" <[EMAIL PROTECTED]> Rhino wrote: >> The MIDlet suite is the JAR file. It's referred to as a suite since it >> can contain more than a single MIDlet. >> > I'm glad I asked! From the context in the FAQ, I got the impression that > it was *at least* the JAR *and* the JAD and possibly other things too. So > am I right in understanding that ONLY the JAR has to be deployed and that > the JAD doesn't get deployed? If so, why create the JAD in the first > place? No, that's incorrect. The JAD file is used by the Application Management System. It lets the AMS determine if the MIDlet suite already exists on the device and, if so, if you're attempting to download a newer version of the suite. It lets the handset determine a lot of information about the MIDlet suite without having to actually download it (which can be costly); since the JAD is usually only a few hundred bytes, it's faster and cheaper to download that than to download the JAR itself, which can be up to 64k and even larger. The JAD file is not *required* by the specification, but most handsets won't accept a JAR, but instead they require the JAD and install what's specified in the MIDlet-Jar-URL field. -- /** * @author Darryl L. Pierce <[EMAIL PROTECTED]> * @see The Infobahn Offramp <http://mcpierce.multiply.com> * @quote "Lobby, lobby, lobby, lobby, lobby, lobby..." - Adrian Monk */ ========================================================================== TOPIC: Developing MIDlet for PDAs and cell phones http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5d0109d66581670e ========================================================================== == 1 of 3 == Date: Fri, Oct 29 2004 11:30 am From: "Darryl L. Pierce" <[EMAIL PROTECTED]> Rhino wrote: > I am a member of a small club and several people in the club have PDAs and > cell phones. If I want to make an application that each of our members can > use on their existing PDAs and cell phones (assuming their cells can even > run MIDlets) what exactly do I need to know about each of their devices to > develop MIDlets that will run on all their devices (at least those that > are capable of running MIDlets)? The whole point of the MIDP is that you shouldn't *need* to know anything about the handset in order to run the application. With that said, there are, obviously, exceptions. For example, with the MIDP 1.0 and low level graphics you will quickly find that there's no standard keycode for things like softkeys and anything outside of the ITU-9 keypad. You'll also find that different handsets render graphics different; i.e., the Samsung A600 won't paint any part of a graphic that extends below the screen height, if you have a background that's taller than the screen then only the top half will render even if you do XY translations. > In other words, rather than writing toward a specific device, e.g. Nokia > CP1111 cellphone, and requiring everyone to have that device, I want to > write MIDlets that will run on a (small) known set of devices. How do I > determine the capabilities of those devices so that I know what the lowest > common denominator MIDP, CLDC, etc. I need to use in doing the > development? What capabilities are you looking for? The MIDP requires that the LCDUI components be supported and that the device provide some level of persistent storage and HTTP networking. Outside of that set (which is complete enough for most applications) what do you need? -- /** * @author Darryl L. Pierce <[EMAIL PROTECTED]> * @see The Infobahn Offramp <http://mcpierce.multiply.com> * @quote "Lobby, lobby, lobby, lobby, lobby, lobby..." - Adrian Monk */ == 2 of 3 == Date: Sat, Oct 30 2004 6:15 am From: "Rhino" <[EMAIL PROTECTED]> "Darryl L. Pierce" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Rhino wrote: > > > I am a member of a small club and several people in the club have PDAs and > > cell phones. If I want to make an application that each of our members can > > use on their existing PDAs and cell phones (assuming their cells can even > > run MIDlets) what exactly do I need to know about each of their devices to > > develop MIDlets that will run on all their devices (at least those that > > are capable of running MIDlets)? > > The whole point of the MIDP is that you shouldn't *need* to know anything > about the handset in order to run the application. > Yeah, that's basically what I thought but the fact that there are already two levels, MIDP-1.0 and MIDP-2.0 with others presumably on the horizon, plus different levels of CLDP, and other Profile stuff like the Personal Basis, made me think that I might have to be sensitive to what versions or levels of each that the different devices are running. However, I am still VERY new to the whole world of MIDlets so the concepts haven't really sunk in yet. > With that said, there are, obviously, exceptions. For example, with the MIDP > 1.0 and low level graphics you will quickly find that there's no standard > keycode for things like softkeys and anything outside of the ITU-9 keypad. > You'll also find that different handsets render graphics different; i.e., > the Samsung A600 won't paint any part of a graphic that extends below the > screen height, if you have a background that's taller than the screen then > only the top half will render even if you do XY translations. > > > In other words, rather than writing toward a specific device, e.g. Nokia > > CP1111 cellphone, and requiring everyone to have that device, I want to > > write MIDlets that will run on a (small) known set of devices. How do I > > determine the capabilities of those devices so that I know what the lowest > > common denominator MIDP, CLDC, etc. I need to use in doing the > > development? > > What capabilities are you looking for? The MIDP requires that the LCDUI > components be supported and that the device provide some level of > persistent storage and HTTP networking. Outside of that set (which is > complete enough for most applications) what do you need? > I'm not sure yet. I'm still just at the design stage for a few MIDlets so I haven't thought the whole design through. I like to use colour though and I read that colour isn't available in MIDP-1.0 (or was it CLDC-1.0?). Ditto for custom controls. But I may be able to write something satisfactory with just MIDP-1.0 and grayscale. Or maybe I'll write two versions of my MIDlet, one for MIDP-2.0/colour/custom controls and a more primitive version for MIDP-1.0/grayscale/standard controls. Like I said, I'm new to MIDlets and only started looking at them on Thursday, at which point I knew nothing at all about MIDlets. Rhino == 3 of 3 == Date: Sat, Oct 30 2004 6:22 am From: "Darryl L. Pierce" <[EMAIL PROTECTED]> Rhino wrote: >> The whole point of the MIDP is that you shouldn't *need* to know anything >> about the handset in order to run the application. >> > Yeah, that's basically what I thought but the fact that there are already > two levels, MIDP-1.0 and MIDP-2.0 with others presumably on the horizon, Nope, there are no new MIDP versions on the horizon. MIDP 2.0 is the latest and is only now becoming prevalent on handsets. > plus different levels of CLDP, and other Profile stuff like the Personal > Basis, made me think that I might have to be sensitive to what versions or > levels of each that the different devices are running. However, I am still > VERY new to the whole world of MIDlets so the concepts haven't really sunk > in yet. The Personal Profile will only be on larger handsets, tablet PCs and settop and headless devices. I doubt you'll find them on mobiles anytime in the near future. My recommendation is to focus on MIDP 1.0 or, if the handsets are new enough, MIDP 2.0. >> > In other words, rather than writing toward a specific device, e.g. >> > Nokia CP1111 cellphone, and requiring everyone to have that device, I >> > want to write MIDlets that will run on a (small) known set of devices. >> > How do I determine the capabilities of those devices so that I know >> > what the > lowest >> > common denominator MIDP, CLDC, etc. I need to use in doing the >> > development? >> >> What capabilities are you looking for? The MIDP requires that the LCDUI >> components be supported and that the device provide some level of >> persistent storage and HTTP networking. Outside of that set (which is >> complete enough for most applications) what do you need? >> > I'm not sure yet. I'm still just at the design stage for a few MIDlets so > I haven't thought the whole design through. I like to use colour though > and I read that colour isn't available in MIDP-1.0 (or was it CLDC-1.0?). You have no control over the colors of high-level UI widgets (i.e., the Form class, Item classes and List and TextBox) but you do have color for doing your own graphics via Canvas. > Ditto for custom controls. But I may be able to write something > satisfactory with just MIDP-1.0 and grayscale. Or maybe I'll write two > versions of my MIDlet, one for MIDP-2.0/colour/custom controls and a more > primitive version for MIDP-1.0/grayscale/standard controls. Like I said, > I'm new to MIDlets and only started looking at them on Thursday, at which > point I knew nothing at all about MIDlets. If you're using Form-based UIs (the most portable) then you can forget about color, you'll have no control over it. If you're talking games you can do color. What *kind* of app are you talking about? -- /** * @author Darryl L. Pierce <[EMAIL PROTECTED]> * @see The Infobahn Offramp <http://mcpierce.multiply.com> * @quote "Lobby, lobby, lobby, lobby, lobby, lobby..." - Adrian Monk */ ========================================================================== TOPIC: Stupid null pointer exception http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aeeebd0bb6f11be3 ========================================================================== == 1 of 4 == Date: Sat, Oct 30 2004 5:50 am From: [EMAIL PROTECTED] (Tony McGrath) This here is some code I have been writing as part of my final year project in Comp Sci. It is a traffic simulator and this is a test class to try and run a text based version of a simle straiht road. However when i run it i only seem to get a null pointer exception the whole time. Can anyone help. The arrray should contain objects of type Bollox, which in this case contains informationon each cell. ie does it contain a car or not and if so whats its speed. Much appreciated cheers. public class Bollox { Cells road1[] = new Cells[200]; Cells road2[] = new Cells[200]; private class Cells{ public void Cells(){ Cells Cell = new Cells(); } boolean isEmpty; boolean isCar; int velocity = 0; int maxVelocity = 0; public void setVelocity(int vel){ velocity = vel; } public void setEmpty(){ isEmpty = true; } public void setNotEmpty(){ isEmpty = false; } public void setIsCar(){ isCar = true; } public void setIsNotCar(){ isCar = false; } public boolean isEmpty(){ return isEmpty = true; } public boolean isCar(){ return isCar = true; } public int getVelocity(){ return velocity; } public void velocity(int i){ int x = 1; int temp = 0; if(isCar()){ maxVelocity = 12; }else{ maxVelocity = 10; } do{ if(road1[i+x].isEmpty() && temp < maxVelocity){ temp++; road2[i+x].setEmpty(); x++; }else{ if(temp < velocity){ velocity = temp; break; }else{ int ran = (int)(Math.random()*1); if(ran == 0 && velocity + 2 <= maxVelocity){ velocity = velocity + 2; isEmpty = false; road2[i+x] = road1[i+x]; break; }else if(velocity + 1 <= maxVelocity){ velocity++; isEmpty = false; road2[i+x] = road1[i+x]; break; }else{ velocity = velocity; road2[i+x] = road1[i+x]; isEmpty = false; break; } } } } while (road1[i+x].isEmpty()); } public void addVehicle(){ road1[0].setNotEmpty(); int ran = (int)(Math.random()*8); if(ran == 3){ road1[0].setIsNotCar(); road1[0].setVelocity(7); }else{ road1[0].setIsCar(); road1[0].setVelocity(9); } } public void printOut(){ System.out.println(""); for(int i = 0; i < 200; i++){ if(road1[i].isEmpty()){ System.out.print(" "); }else{ if(road1[i].isCar()){ System.out.print("."); }else{ System.out.print("#"); } } } } public void swap(int i){ road1[i] = road2[i]; } } void run(){ for(int i = 0; i < 200; i++){ Cells cell1 = road1[i]; Cells cell2 = road2[i]; cell1.swap(i); } } //void swap(){ //swap(); //} } class MainC extends Thread{ public static void main(String[] args){ Bollox b = new Bollox(); boolean go = true; while(go){ b.run(); try{Thread.sleep(100);} catch(InterruptedException e){} } } } == 2 of 4 == Date: Sat, Oct 30 2004 6:17 am From: Daniel Sjöblom <[EMAIL PROTECTED]> Tony McGrath wrote: <snip> There is probably very much else wrong with this code, but this is what I found on a cursory look: > > public class Bollox { > > Cells road1[] = new Cells[200]; > Cells road2[] = new Cells[200]; You do know that this only allocates the arrays to hold the Cell objects, not the objects in the array slots? To allocate the Cells objects you must do: for (int i = 0; i < road.length; i++) road[i] = new Cells(); > private class Cells{ > > public void Cells(){ > Cells Cell = new Cells(); > } What is the above supposed to do? This will result in an infinite loop. > public boolean isEmpty(){ > return isEmpty = true; > } This does not do what the name implies it does. This will always set isEmpty to true and return true. > class MainC extends Thread{ > public static void main(String[] args){ > Bollox b = new Bollox(); > boolean go = true; > while(go){ > b.run(); > try{Thread.sleep(100);} > catch(InterruptedException e){} What is this supposed to do? -- Daniel Sjöblom Remove _NOSPAM to reply by mail == 3 of 4 == Date: Sat, Oct 30 2004 6:23 am From: Thomas Schodt <[EMAIL PROTECTED]> Tony McGrath wrote: > Cells road1[] = new Cells[200]; > Cells road2[] = new Cells[200]; You allocate two arrays that hold references to Cells objects (initially all these references are null). You did not create the 400 Cells objects that you presumably want the arrays to reference Also, there are problems in your isEmpty() and isCar() methods. == 4 of 4 == Date: Sat, Oct 30 2004 7:56 am From: "xarax" <[EMAIL PROTECTED]> "Daniel Sjöblom" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Tony McGrath wrote: > <snip> > > There is probably very much else wrong with this code, but this is what > I found on a cursory look: > > > > > public class Bollox { > > > > Cells road1[] = new Cells[200]; > > Cells road2[] = new Cells[200]; > > You do know that this only allocates the arrays to hold the Cell > objects, not the objects in the array slots? To allocate the Cells > objects you must do: > > for (int i = 0; i < road.length; i++) > road[i] = new Cells(); > > > private class Cells{ > > > > public void Cells(){ > > Cells Cell = new Cells(); > > } > > What is the above supposed to do? This will result in an infinite loop. Look more closely at the method. It is not a constructor. It is just wasting time and space by creating an instance that is never used. The OP should review the guidelines for naming packages, classes, methods, and fields. > > public boolean isEmpty(){ > > return isEmpty = true; > > } > > This does not do what the name implies it does. This will always set > isEmpty to true and return true. The OP is confusing "=" with "==". Probably better to just "return isEmpty;", but I cannot see where "isEmpty" is correctly assigned. > > class MainC extends Thread{ > > public static void main(String[] args){ > > Bollox b = new Bollox(); > > boolean go = true; > > while(go){ > > b.run(); > > try{Thread.sleep(100);} > > catch(InterruptedException e){} > > What is this supposed to do? I have no clue. ========================================================================== TOPIC: array comparison and sort http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4208721fbec39fc3 ========================================================================== == 1 of 2 == Date: Sat, Oct 30 2004 6:41 am From: [EMAIL PROTECTED] (vic) Hello All, I am running into this problem of getting my array to output the desired results. Below is the problem i have two string arrays via String[] ar1 = {1,2,1,4,1,2}; String[] ar2 = {7,3,7,5,7,3}; each array contains 6 elements. i want to do something like this compare elements of ar1 and ar2 with one another and the moment it encounters a true condition, e.g in the above example when (ar1[0].equals(ar1[2])) && (ar2[0].equals(ar2[2])) then i want to array pointer to move to ar1[1] and ar2[1] so that it starts comparing from index->1 and same logic apllies. The output would be something like this for the first iteration ar1 = {2,1,4,1,2} ar2 = {3,7,5,7,3} now if we applied same logic in a loop output would be ar1 = {1,4,1,2} ar2 = {7,5,7,3} and final output ar1 = {4,1,2} ar2 = {5,7,3} The final output should have a unique set of values Appreciate any help thanks vivi == 2 of 2 == Date: Sat, Oct 30 2004 7:14 am From: Chris Smith <[EMAIL PROTECTED]> [EMAIL PROTECTED] says... > I am running into this problem of getting my array to output the > desired results. Below is the problem > > i have two string arrays via > > String[] ar1 = {1,2,1,4,1,2}; > String[] ar2 = {7,3,7,5,7,3}; > > each array contains 6 elements. The code above yields a syntax error. I'd like to ignore that, but I'm unsure if you meant to declare an array of String, or an array of int. > i want to do something like this > > compare elements of ar1 and ar2 with one another and the moment it > encounters a true condition, e.g in the above example when > > (ar1[0].equals(ar1[2])) && (ar2[0].equals(ar2[2])) > > then i want to array pointer to move to ar1[1] and ar2[1] so that it > starts comparing from index->1 and same logic apllies. The output > would be something like this for the first iteration There is no such thing as an array "pointer" moving. References to objects in Java (including references to arrays) always point to the beginning of the object. You would need to actually remove the data, not just move a reference. So you basically want to remove the first occurrences of any duplicates between the arrays? Since you can't resize an array or delete its elements, you might start out by considering a different data structure, such as ArrayList or LinkedList. Then you can simply call remove(int) to remove whatever values you find duplicates of. -- www.designacourse.com The Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation ========================================================================== TOPIC: Java Web Start and Directory Structure http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/84343be35a56594c ========================================================================== == 1 of 1 == Date: Sat, Oct 30 2004 8:15 am From: [EMAIL PROTECTED] (Ron) JWS Gurus, I am new to Java Web Start. I have an application that reads different config files from config directory and uses bin files to execute commands internally. The directory structure looks something like this: + <install dir>| |- MyApp| |-lib (all jar files needed for app) |-app| <user.dir>|-bin (app is currently launched from) |-files| |-config How can I package this app so I could install on clients remotely using java web start with none to least user interaction. FYI my app uses user.dir system property(which is path to my bin dir) to get absolute paths. Moreover, I tried a sample application using user.dir but path returned is client's system32 directory. Any help would be highly appreciated. Thanks Ron. ========================================================================== TOPIC: applet's call comportement http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc1d4563dc67060c ========================================================================== == 1 of 1 == Date: Sat, Oct 30 2004 8:46 am From: "Emmanuel Freund" <[EMAIL PROTECTED]> > You *need* to become intimately familiar with Java class loading and > ClassLoaders, the mechanism by which Java's dynamic linking behavior > operates. You would benefit from studying the details of the class file > format. I think that you will find that you cannot do what you describe > without an enormous amount of work, and that you may not be able to do > it at all. Specifically: > > You _could_ define a custom ClassLoader for your application that would > load a class of your choice instead of the platform library's > javax.swing.JFrame (for instance). However, if that class' FQ name is > anything other than javax.swing.JFrame then the VM will throw an Error. > If that class' name _is_ javax.swing.JFrame then it must be a complete > reimplementation of JFrame (i.e. it cannot extend the system's JFrame > because there is a name collision). You cannot use Sun's code for this > without violating your Java license, but you must be certain to be 100% > accurate in fulfilling the published JFrame contract or some applets > will break. (In fact, any applet that depends on serializing / > deserializing a JFrame is likely to break no matter what you do.) In > addition, if you did do this then you would then be locked into > _maintaining_ your versions of these classes. > This class loader thing is interesting, i will work on it. > I am not a GUI expert, but my inclination is to say that you're going > about this in the wrong way. It seems to me that a better way to > accomplish your aim might be for your application to use a custom AWT > Toolkit instead of trying to modify or substitute System classes. The > details of how that would work (including how you would specify the > appropriate Toolkit class to the system) are beyond what I'm prepared to > research at this time. The AWT and Swing classes are designed to be > customizable for a wide range of environments; it would be better to > make use of that to modify their behavior, rather than to try to replace > them. Well, the AWT toolkit's environnement don't match the things i want to render. But i aggree it would be simpler in this way. I'm just wondering, when an applet call the JFrame class for example, there has to be somewhere the path where the applet could find this class, so if we change the path toward my own class, the applet will call my own class instead, no? even if my own class is a child of JFrame? unless i've really none understand, which is a possibility... Thanks for all anyway, a lot. -- Emmanuel [EMAIL PROTECTED] ======================================================================= 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
