comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * JTextArea question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3b5070301a6779b * Invoking 'diff' from java with piped input - 4 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a587b43b3b207a9f * execution speed java vs. C - 9 messages, 4 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e8713e999b13b7d1 * "static" prefix - to parallel "this" prefix - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f5dde10882ac2157 * Java speed vs. C++. - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e29354c898cb3523 * How to show in java apps - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3dcf03dc2d93da27 * Tool or IDE for function inlining - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/58fb84c0ecba12f0 * MIDP MIDlet: which characters are supported in the phone font? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/73bdfdf7f36c6ea0 * How to convert java applet to java application - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fb08f4f19c14e139 * Interesting design question involving ZIPs and servers - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d93856e0b568e2e4 * comp.lang.java.{help,programmer} - what they're for (mini-FAQ 2004-10-08) - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2235cf41e4c4f22d * Threads and modal dialog behaviour question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7a5f146a46cb92ad * [Applet Dev] Can JSO Object be called "remotely" ? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cf6f83ed2d3c9dfe * Using the Command Pattern and Sockets? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5c34979f54b29d05 ============================================================================== TOPIC: JTextArea question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3b5070301a6779b ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 8:11 am From: "Ryan Tan via JavaKB.com" Yes, I am selecting and copying like you describe. Now I am getting worried... I tried to make a small app with a disabled JTextArea and it the copy functionality still works (you're right!). So now I am pretty sure it's something to do with my large program. I will try and see if I can find the reason for this bug... Thanks for the help Mr Kalakrishnan -- Message posted via http://www.javakb.com ============================================================================== TOPIC: Invoking 'diff' from java with piped input http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a587b43b3b207a9f ============================================================================== == 1 of 4 == Date: Thurs, Dec 9 2004 9:15 am From: David Kensche Gordon Beaton wrote: > On Wed, 08 Dec 2004 17:53:00 +0100, David Kensche wrote: > >>I tried to implement the solution with the named pipes. This is my >>second try. I first tried it without the threads. The result is that >>diff does not produce output, i.e. in the end 'patchString' is null. >>When I don't flush nor close the writers I get the same behaviour. >>On the other hand, if I flush or close (or both) diff does not >>terminate. Do you know how to handle these streams? > > > Your code works when I run it, however there may be a race condition > when you create the fifos in a separate thread. Do you know that they > exist before diff attempts to open them? Create the fifos in the main > thread; write to them in the writer threads. > > Also, in your example, you wait for diff to finish before getting the > output stream. To avoid deadlocking, you need to read from diffs > output while it runs. If diff's output stream fills and there is > nobody reading from it, diff is prevented from continuing (and you > block waiting for it). > > /gordon > Thank you, now it works fine :-). The problem was my waiting for diff before reading the result. This is my running code: public PatchScript createPatch(final String orig, final String rev) throws DiffFailedException { PatchScript patch = null; try { logger.debug("Create named pipes to write input to."); Runtime.getRuntime().exec("mkfifo " + ORIG_PIPE_NAME); Runtime.getRuntime().exec("mkfifo " + REV_PIPE_NAME); logger.debug("Write input to named pipes."); new Thread() { public void run() { try { logger.debug("Open pipe:" + ORIG_PIPE_NAME); File oPipe = new File(ORIG_PIPE_NAME); if(oPipe.exists()) { FileWriter oWriter = new FileWriter(oPipe); oWriter.write(orig); oWriter.flush(); oWriter.close(); logger.debug("Revision written. rWriter closed."); } else logger.warn("Could not find named pipe: " + ORIG_PIPE_NAME); } catch(IOException e) { logger.warn("Could not write 'orig' to named pipe.", e); } } }.start(); new Thread() { public void run() { try { logger.debug("Open pipe:" + REV_PIPE_NAME); File rPipe = new File(REV_PIPE_NAME); if(rPipe.exists()) { FileWriter rWriter = new FileWriter(rPipe); rWriter.write(rev); rWriter.flush(); rWriter.close(); logger.debug("Revision written. rWriter closed."); } else logger.warn("Could not find named pipe: " + REV_PIPE_NAME); } catch(IOException e) { logger.warn("Could not write 'rev' to named pipe.", e); } } }.start(); logger.debug("Start 'diff' process."); Process diffProc = Runtime.getRuntime().exec("diff -u original revision"); logger.debug("Read result."); BufferedReader reader = new BufferedReader(new InputStreamReader(diffProc.getInputStream())); String line = reader.readLine(); String patchString = null; if(line != null) patchString = line; while((line = reader.readLine()) != null) patchString += line + "\n"; logger.debug("patch=\n" + patchString); logger.debug("Wait for 'diff' to finish."); diffProc.waitFor(); logger.debug("diff-status="+diffProc.exitValue()+". Read patch script."); patch = parser.parse(patchString); } catch(Exception e) { throw new DiffFailedException("Could not create patch script!", e); } return patch; } == 2 of 4 == Date: Thurs, Dec 9 2004 9:18 am From: David Kensche Alan Gutierrez wrote: > On 2004-12-08, Michael Borgwardt <[EMAIL PROTECTED]> wrote: > >>David Kensche wrote: >> >> >>>Hello, >>>I want to call GNU diff from a java class with the following command >> >>[] >> >>>My problem is: how do I give the input? I assume there has to be a >>>way to pipe the Strings to the process but I can't make out how. >> >>Just write them to a file, then give the file name as argument. No, >>there is no other way, because a process can have only one input stream. >> >>The other way would be to find and use a diff implementation in Java. > > > Like, for example, the diff algorithm that comes with Eclipse. > > It is under org.eclipse.compare. > > I've extracted it for use with a testing framework. It is very easy > to use, and it is cross-platform pure Java. > > -- > Alan Gutierrez - [EMAIL PROTECTED] Hello, my first implementation used jrcs but this was prohibitively slow in patching. This is why I decided to try GNU diff/patch. But to be honest I thought about trying eclipse instead but I was sure, that eclipse uses diff and patch as provided by the cvs installation. But if there is a java implementation, I will try this, too. Thanks, David == 3 of 4 == Date: Thurs, Dec 9 2004 9:39 am From: David Kensche David Kensche wrote: > Gordon Beaton wrote: > >> On Wed, 08 Dec 2004 17:53:00 +0100, David Kensche wrote: >> >>> I tried to implement the solution with the named pipes. This is my >>> second try. I first tried it without the threads. The result is that >>> diff does not produce output, i.e. in the end 'patchString' is null. >>> When I don't flush nor close the writers I get the same behaviour. >>> On the other hand, if I flush or close (or both) diff does not >>> terminate. Do you know how to handle these streams? >> >> >> >> Your code works when I run it, however there may be a race condition >> when you create the fifos in a separate thread. Do you know that they >> exist before diff attempts to open them? Create the fifos in the main >> thread; write to them in the writer threads. >> >> Also, in your example, you wait for diff to finish before getting the >> output stream. To avoid deadlocking, you need to read from diffs >> output while it runs. If diff's output stream fills and there is >> nobody reading from it, diff is prevented from continuing (and you >> block waiting for it). >> >> /gordon >> > Thank you, > now it works fine :-). The problem was my waiting for diff before > reading the result. This is my running code: > Damn, I was wrong. The only reason why it worked was that I forgot to replace the filenames in the diff invocation by the newly introduced constants (which had different values). Thus the diff read from pipes which were created in earlier tests and the pipes created by the given code were not read from at all! I now corrected this but the 'original.fifo' cannot be found, even if I switch the order of the two writer threads. I think I got something seriously wrong with thread programming? public PatchScript createPatch(final String orig, final String rev) throws DiffFailedException { PatchScript patch = null; try { logger.debug("Create named pipes to write input to."); Runtime.getRuntime().exec("mkfifo " + ORIG_PIPE_NAME); Runtime.getRuntime().exec("mkfifo " + REV_PIPE_NAME); long millis = System.currentTimeMillis() + 5000; while(System.currentTimeMillis() < millis) {} logger.debug("Write input to named pipes."); new Thread() { public void run() { try { logger.debug("Open pipe:" + ORIG_PIPE_NAME); File oPipe = new File(ORIG_PIPE_NAME); if(oPipe.exists()) { FileWriter oWriter = new FileWriter(oPipe); oWriter.write(orig); oWriter.flush(); oWriter.close(); logger.debug("Original written. Writer closed."); } else logger.warn("Could not find named pipe: " + ORIG_PIPE_NAME); } catch(IOException e) { logger.warn("Could not write 'orig' to named pipe.", e); } } }.start(); new Thread() { public void run() { try { logger.debug("Open pipe:" + REV_PIPE_NAME); File rPipe = new File(REV_PIPE_NAME); if(rPipe.exists()) { FileWriter rWriter = new FileWriter(rPipe); rWriter.write(rev); rWriter.flush(); rWriter.close(); logger.debug("Revision written. Writer closed."); } else logger.warn("Could not find named pipe: " + REV_PIPE_NAME); } catch(IOException e) { logger.warn("Could not write 'rev' to named pipe.", e); } } }.start(); logger.debug("Start 'diff' process."); Process diffProc = Runtime.getRuntime().exec("diff -u " + ORIG_PIPE_NAME + " " + REV_PIPE_NAME); logger.debug("Read result."); BufferedReader reader = new BufferedReader(new InputStreamReader(diffProc.getInputStream())); String line = reader.readLine(); String patchString = null; if(line != null) patchString = line + "\n"; while((line = reader.readLine()) != null) patchString += line + "\n"; logger.debug("patch=\n" + patchString); logger.debug("Wait for 'diff' to finish."); diffProc.waitFor(); logger.debug("diff-status="+diffProc.exitValue()+". Read patch script."); patch = parser.parse(patchString); } catch(Exception e) { throw new DiffFailedException("Could not create patch script!", e); } return patch; } == 4 of 4 == Date: Thurs, Dec 9 2004 9:58 am From: Gordon Beaton On Thu, 09 Dec 2004 09:15:08 +0100, David Kensche wrote: > Thank you, > now it works fine :-). The problem was my waiting for diff before > reading the result. This is my running code: Good you got it working, but after suggesting that you use fifos I realized that using fifos and temporary files involve virtually the same steps. The difference is that the fifo solution doesn't require (much) disk space, but it's the less portable alternative and additionally the fifos need to be explicitely created. In retrospect, I would have used temporary files. Note that you only needed to create one fifo, since diff will read one of the "files" from stdin if you specify "-" as the filename. /gordon -- [ do not email me copies of your followups ] g o r d o n + n e w s @ b a l d e r 1 3 . s e ============================================================================== TOPIC: execution speed java vs. C http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e8713e999b13b7d1 ============================================================================== == 1 of 9 == Date: Thurs, Dec 9 2004 9:27 am From: "Skip" > So I went ahead and wrote a very simple matrix multiplication program > in C and Java and benchmarked them. To my disappointment, C turned out > to be about 1.5 to 2 times faster than Java. > int a [][] = new int [N][M]; > int b [][] = new int [N][M]; > int c [][] = new int [N][M]; In java every array is a separate object, if you do: > int a [] = new int [N*M]; > int b [] = new int [N*M]; > int c [] = new int [N*M]; your code will be a LOT faster. further: you benchmark only the first run it seems. the HotSpot JIT seems to optimize the code only after the same code block is run a couple of times (normally the 2nd time). your plain java-code took 16.4s for me. after i optimised it myself: 12.3s after enableding the -server in java commandline 5.9s (you need the java SDK for that) 5.9s / 16.4s = 36% of the time it took, *2.78x faster* * so with my own optimisation, and -server your java app will be faster than C -O3 * (even surprises me!) ~~~~~~~~~~ here is my optimised sourcecode: private final int N = 800; private final int M = 800; private final int a[] = new int[N * M]; private final int b[] = new int[N * M]; private final int c[] = new int[N * M]; public final void method1() { int range = N * M; for (int i = 0; i < range; ++i) { a[i] = (int) ((Math.random() - 0.5) * 10.0); } } public final void method2() { int range = N * M; for (int i = 0; i < range; ++i) { c[i] = 0; } } public final void method3() { for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) { for (int k = 0; k < M; ++k) { c[i + j * N] += a[i + k * N] * b[k + j * N]; } } } } == 2 of 9 == Date: Thurs, Dec 9 2004 10:03 am From: "Skip" > > So I went ahead and wrote a very simple matrix multiplication program > > in C and Java and benchmarked them. To my disappointment, C turned out > > to be about 1.5 to 2 times faster than Java. > > > int a [][] = new int [N][M]; > > int b [][] = new int [N][M]; > > int c [][] = new int [N][M]; > > In java every array is a separate object, if you do: > > > int a [] = new int [N*M]; > > int b [] = new int [N*M]; > > int c [] = new int [N*M]; > > your code will be a LOT faster. > > further: you benchmark only the first run it seems. the HotSpot JIT seems to > optimize the code only after the same code block is run a couple of times > (normally the 2nd time). > > your plain java-code took 16.4s for me. > after i optimised it myself: 12.3s > > after enableding the -server in java commandline 5.9s (you need the java SDK > for that) May I add that the same calculations on float-matrices takes only 4.6s (java 1.4.2+ uses SSE), results are ofcourse slightly inaccurate. == 3 of 9 == Date: Thurs, Dec 9 2004 10:19 am From: Michael Borgwardt Skip wrote: >>int a [][] = new int [N][M]; >>int b [][] = new int [N][M]; >>int c [][] = new int [N][M]; > > > In java every array is a separate object, if you do: > > >>int a [] = new int [N*M]; >>int b [] = new int [N*M]; >>int c [] = new int [N*M]; > > > your code will be a LOT faster. Why? Allocating the arrays happens only once at the beginning of the program. Should not be relevant. > > further: you benchmark only the first run it seems. the HotSpot JIT seems to > optimize the code only after the same code block is run a couple of times > (normally the 2nd time). That and not using -server seem to be the biggest factors to me. == 4 of 9 == Date: Thurs, Dec 9 2004 1:25 am From: "Alex" I agree that hotspot compilers do much better work compared to years ago. Your test again too simple. Matrix mul is nothing. Compiler option -O3 is not enough to gain maximum from GCC, its only query to make code optimized, not absolutely fast. So, please force a bunch of actual comand line options. You should be surprised.. Try to feed FFT code or something complex (search for Ooura FFT). I think you may get more real numbers, at least ~8-10 times slower java code. Try: 1. Use Intel optimizing compiler. 2. Enable Your CPU model optimization 2. Enable MMX/SSE/SSE2 optimizations 3. Enable Full functions inline (more: interprocedural and intermodular optimizations). 4. Enable unrolling loops We can talk about java JIT optimiser as weak (but fast) c-compiler like borland turbo C, which tends to inline most of code. Nothing more. Latest C/C++ compilers when they turned to do all what they might to do, is ALWAYS faster than java JIT. == 5 of 9 == Date: Thurs, Dec 9 2004 10:50 am From: "Skip" > >>int a [] = new int [N*M]; > >>int b [] = new int [N*M]; > >>int c [] = new int [N*M]; > > > > > > your code will be a LOT faster. > > Why? Allocating the arrays happens only once at the beginning of the program. > Should not be relevant. It's about access times. IIRC: int[64] is a block of 64 ints in memory int[16][4] are 16 blocks of 4 ints. so the JVM has to find int[x][] first, then int[x][y] and i proved it's faster. 16.9s ---> 12.3s i did this optimization very often, and it was always much faster, as you just saw. HTH == 6 of 9 == Date: Thurs, Dec 9 2004 1:16 am From: Mike Cox Skip wrote: >> So I went ahead and wrote a very simple matrix multiplication program >> in C and Java and benchmarked them. To my disappointment, C turned out >> to be about 1.5 to 2 times faster than Java. > >> int a [][] = new int [N][M]; >> int b [][] = new int [N][M]; >> int c [][] = new int [N][M]; > > In java every array is a separate object, if you do: > >> int a [] = new int [N*M]; >> int b [] = new int [N*M]; >> int c [] = new int [N*M]; > > your code will be a LOT faster. > > further: you benchmark only the first run it seems. the HotSpot JIT seems > to optimize the code only after the same code block is run a couple of > times (normally the 2nd time). HotSpot JIT, is that SUN's JIT compiler or is that some third-part code that compiles native code? > > your plain java-code took 16.4s for me. > after i optimised it myself: 12.3s > > after enableding the -server in java commandline 5.9s (you need the java > SDK for that) In the java command or in javac? I'm testing out Tomcat, so could I compile a servlet with the server option, like so: javac -server myjava.java In the same thought, is it possible to compile a java servlet into native code so it runs super fast on Tomcat? == 7 of 9 == Date: Thurs, Dec 9 2004 11:08 am From: Michael Borgwardt Skip wrote: > It's about access times. > > IIRC: > int[64] is a block of 64 ints in memory > int[16][4] are 16 blocks of 4 ints. > > so the JVM has to find int[x][] first, then int[x][y] That's only relevant if x is different for each access, otherwise the result should be in first-level CPU cache and retrieval so fast that it doesn't matter. So it depends on the access patterns of the concrete application > and i proved it's faster. > > 16.9s ---> 12.3s It sounded to me like that was the result after the code change *and* giving the Hotspot compiler time to optimize the method. > i did this optimization very often, and it was always much faster, as you > just saw. I wouldn't call it *much* faster, A factor of 5, *that's* "much faster", and not at all an uncommon achievement. But of course every improvement helps. == 8 of 9 == Date: Thurs, Dec 9 2004 11:49 am From: Michael Borgwardt Mike Cox wrote: >>further: you benchmark only the first run it seems. the HotSpot JIT seems >>to optimize the code only after the same code block is run a couple of >>times (normally the 2nd time). > > > HotSpot JIT, is that SUN's JIT compiler or is that some third-part code that > compiles native code? The former. >>after enableding the -server in java commandline 5.9s (you need the java >>SDK for that) > > > In the java command or in javac? I'm testing out Tomcat, so could I compile > a servlet with the server option, like so: javac -server myjava.java No, it's a runtime option, not a compiler option. > In the same thought, is it possible to compile a java servlet into native > code so it runs super fast on Tomcat? That's neither possible nor would it run "super fast". == 9 of 9 == Date: Thurs, Dec 9 2004 3:01 am From: Michael Borgwardt Alex wrote: > Your test again too simple. > Matrix mul is nothing. Compiler option -O3 is not enough to gain > maximum from GCC, its only query to make code optimized, not absolutely > fast. So, please force a bunch of actual comand line options. You > should be surprised.. > > Try to feed FFT code or something complex (search for Ooura FFT). I > think you may get more real numbers, at least ~8-10 times slower java > code. Those are pretty big claims. Why not do that yourself and show us the numbers? > We can talk about java JIT optimiser as weak (but fast) c-compiler like > borland turbo C, which tends to inline most of code. Nothing more. That is untrue. Java JIT compilers can theoretically do anything that C compilers can do, and more (since they have more information about the current machine) and in practice the Hotspot JIT, as of 1.4.1, performs inlining loop unrolling, dead code elimination, loop invariant hoisting, common subexpression elimination, constant propagation, as well as optimization of register usage and a lot of Java-specific stuff. > Latest C/C++ compilers when they turned to do all what they might to > do, is ALWAYS faster than java JIT. Perhaps faster than a particular JIT, perhaps even faster than the best current JIT, but in full generality that statement can only be untrue. ============================================================================== TOPIC: "static" prefix - to parallel "this" prefix http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f5dde10882ac2157 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 8:53 am From: "Chris Uppal" Tim Tyler wrote: > Otherwise you wind up with the Java situation - where there's a > whole bunch of extra material in the JLS to deal specifically > with static entities, how they are (or aren't) inherited - what > happens when a member variable overrides a static one in an > inherited class - and so on - all pointless irregularity Oh, I agree entirely. > that makes the langage harder to learn and use. -- chris ============================================================================== TOPIC: Java speed vs. C++. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e29354c898cb3523 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 9:24 am From: Piotr Plazienski Joona I Palaste wrote: > Dan Elliott <[EMAIL PROTECTED]> scribbled the following > on comp.lang.java.programmer: > >>"Mike Cox" <[EMAIL PROTECTED]> wrote in message >>news:[EMAIL PROTECTED] >> >>>Hi. I recently ran a benchmark against two simple programs, one written >> >>in >> >>>Java and the other in C++. The both accomplish the same thing, outputting >>>"Hello World" on my screen. The C++ program took .5 seconds to complete >> >>on >> >>>my 400 Mhz PC while the Java program took 6.5 seconds. >>> >>>I am running the SUSE 8.2 Linux distribution. >>> >>>Why is Java that much slower than the C++ program? I read on Slashdot >> >>that >> >>>Java was almost as fast as C++. Here are my programs: >>> >>>test.cpp >>> >>>#include <iostream> >>>using namespace std; >>>int main() >>>{ >>> cout<<"Hello World"; >>>} >>> >>> >>>test.java >>> >>>public class test >>>{ >>> public static void main(String[] args) >>> { >>> System.out.println("Hello world"); >>> } >>>} >>> >>>The reason I ask is because I'm thinking of using Apache and Jakarta to do >>>some development. If Java cannot be speeded up, I will be forced to find >>>another alternative. >>> >> >>Mike, > > >>This is a truly pathetic test. I am not sure you could learn ANYTHING of >>value from it. > > > I agree. The overhead of starting the Java process and creating a VM is > way too large in this test. Try to print "Hello world" one million times > in a loop for a fairer test. > Actually that wont't do either. Console has its limits, and outputting anything at that rate makes everything slow down to console speed. My brother 'proved' that perl is working at same speed as c that way. Better (but also silly) is to do loop that outputs something, does something without ouputting, disk usage and so on (like incrementing/decrementing or modulo-ing variable) and does it many times, then execute that loop many more times :D. I mean sometning like that: #include <iostream> using namespace std; int main() { for(i=0; i<many_times;i++) { cout<<"Hello World"; for(j=0;j<many_many_times;j++) { i++; i--; } } } and you have to take many_many_times high enough to slow doen output to maybe one "hello" a second, and many many_times to take program to execute not less than i think 30 secs to reduce impact of preparing a program. ============================================================================== TOPIC: How to show in java apps http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3dcf03dc2d93da27 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 10:20 am From: Michael Borgwardt SG wrote: > I have a small requiremnt. I have key - value paired strings in txt files. > The value will be present in different languages. > My java program should display the value (in different languages ) in list > controls. Any samples? http://java.sun.com/docs/books/tutorial/i18n/resbundle/index.html ============================================================================== TOPIC: Tool or IDE for function inlining http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/58fb84c0ecba12f0 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 1:29 am From: "Alex" I need this because I am programming J2ME with SUN KVM interpreter. The call is cost enormous cpu cycles (I bencmarked it). Also if function body is properly inlined, it gives more chances to javac optimize bytecode and shrinks .class size. ============================================================================== TOPIC: MIDP MIDlet: which characters are supported in the phone font? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/73bdfdf7f36c6ea0 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 1:31 am From: [EMAIL PROTECTED] What is a "locale" and in which locale is "pi"? ============================================================================== TOPIC: How to convert java applet to java application http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fb08f4f19c14e139 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 8:40 pm From: "Rusty Angus" Roughly, you got to change "container" from JApplet to JFrame and you have to set the size of a JFrame and set it to visible. Also there is no JApplet life cycle methods like init() and start() methods but the Java application main(String[] args) method. -- Rusty Angus "Jenny" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > Could you try the code? It does not work. > > > [EMAIL PROTECTED] wrote: >> In article <[EMAIL PROTECTED]>, >> "hllim" <[EMAIL PROTECTED]> wrote: >> > Hi, >> > >> > Is that possible to convert a Java Applet Code to a Java > Application >> Code >> > without doing big modification to my existing Java applet code? >> Please give >> > me some guides... >> > >> > Thank you! >> > >> > >> >> No problem. Just add the following code (with your class name >> modifications) to your class that extends Applet: >> >> public static void main(String args[]) >> { >> YourAppletClassName applet = new YourAppletClassName(); >> Frame frame = new Frame("Needs a Title"); >> frame.addWindowListener(new windowListener()); >> >> // set the layout and add the applet >> frame.setLayout(new GridBagLayout()); >> GridBagConstraints constraints = new GridBagConstraints >> (); >> constraints.gridx = 0; >> constraints.gridy = 0; >> constraints.weightx = 100; >> constraints.weighty = 100; >> constraints.anchor = GridBagConstraints.CENTER; >> constraints.fill = GridBagConstraints.BOTH; >> frame.add(applet, constraints); >> frame.pack(); >> frame.setSize(850, 575); >> frame.validate(); >> >> // Center the window >> Dimension screenSize = Toolkit.getDefaultToolkit >> ().getScreenSize(); >> Dimension frameSize = frame.getSize(); >> if (frameSize.height > screenSize.height) >> { >> frameSize.height = screenSize.height; >> } >> if (frameSize.width > screenSize.width) >> { >> frameSize.width = screenSize.width; >> } >> frame.setLocation((screenSize.width - >> frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); >> frame.setVisible(true); >> } >> >> >> Sent via Deja.com http://www.deja.com/ >> Before you buy. > ============================================================================== TOPIC: Interesting design question involving ZIPs and servers http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d93856e0b568e2e4 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 8:06 pm From: Gregory Toomey [EMAIL PROTECTED] wrote: > Hello Everyone, > > I'm writing a report server that uses servlets and JSP's running > on Apache Tomcat. The reports are XML files that users can submit, and > are stored on the servers file system. Since there will be many, many > reports entered into this server, to save on space I loaded all > completed XML reports into a byte[] buffer (running the XML text > through a ZipOutputStream). So all completed reports are stored in > memory in a compressed zip buffer until the report is needed. This > byte[] buffer is contained in a ReportMetaData class with several other > meta data information describing the report. > > When the report is requested from the ReportMetaData object, the XML > text is unzipped, then parsed in my ReportXMLParser class to give me > the final ReportObject. Any thoughts on my memory management technique? > Is there a more efficient way of doing this? > > OK... So, the problem is, I want to be able to do FREE-FORM TEXT > searches on all of my completed reports. How can I search a zipped > buffer for a specific text string without having to uncompress the > buffer (ruining my memory savings). I could store text keywords with my > meta data object, but thats not really free-form... and that's what the > users are really hopeing for. > Thanks, > > Greg Frommer > [EMAIL PROTECTED] In simple terms ... you're nuts. gtoomey ============================================================================== TOPIC: comp.lang.java.{help,programmer} - what they're for (mini-FAQ 2004-10-08) http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2235cf41e4c4f22d ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 10:25 am From: [EMAIL PROTECTED] (David Alex Lamb) Last-Modified: Fri Oct 8 11:38:42 2004 by David Alex Lamb Archive-name: computer-lang/java/help/minifaq Posting-Frequency: every 4 days Before posting read Jon Skeet's "How to get answers on the comp.lang.java.* newsgroups" at http://www.pobox.com/~skeet/java/newsgroups.html Java FAQs and advice: - Java FAQ (Andrew Thompson) http://www.physci.org/codes/javafaq.jsp including his list of other FAQs http://www.physci.org/codes/javafaq.jsp#faq - Java/Javascript/Powerbuilder HOWTO (Real Gagnon) http://www.rgagnon.com/howto.html - Java Glossary (Roedy Green) http://www.mindprod.com/jgloss.html - jGuru jFAQs (John Zukowski) http://www.jguru.com/jguru/faq/ - Focus on Java (John Zukowski) http://java.about.com/ - Java Q&A (David Reilly) http://www.davidreilly.com/jcb/faq/ - Java GUI FAQ (Thomas Weidenfeller) http://www.physci.org/guifaq.jsp comp.lang.java.help Set-up problems, catch-all first aid. According to its charter, this unmoderated group is for immediate help on any Java problem, especially when the source of the difficulty is hard to pin down in terms of topics treated on other groups. This is the appropriate group for end-users, programmers and administrators who are having difficulty installing a system capable of running Java applets or programs. It is also the right group for people trying to check their understanding of something in the language, or to troubleshoot something simple. comp.lang.java.programmer Programming in the Java language. An unmoderated group for discussion of Java as a programming language. Specific example topics may include: o types, classes, interfaces, and other language concepts o the syntax and grammar of Java o threaded programming in Java - sychronisation, monitors, etc. o possible language extensions (as opposed to API extensions). The original charter said that discussion explicitly should not include API features that are not built into the Java language and gave examples like networking and the AWT. These days AWT belongs in clj.gui, and networking (and many other APIs) are often discussed in clj.programmer. Do not post binary classfiles or long source listings on any of these groups. Instead, the post should reference a WWW or FTP site (short source snippets to demonstrate a particular point or problem are fine). For some problems you might consider posting a SSCCE (Short, Self Contained, Correct (Compilable), Example); see http://www.physci.org/codes/sscce.jsp Don't post on topics that have their own groups, such as: comp.lang.java.3d The Java 3D API comp.lang.java.advocacy Arguments about X versus Y, for various Java X and Y comp.lang.java.beans JavaBeans and similar component frameworks comp.lang.java.corba Common Object Request Broker Architecture and Java comp.lang.java.databases Using databases from Java comp.lang.java.gui Java graphical user interface design and construction comp.lang.java.machine Java virtual machines, like JVM and KVM comp.lang.java.security Using Java securely comp.lang.java.softwaretools Tools for developing/maintaining Java programs Don't cross-post between these groups and c.l.j.programmer or .help -- it just wastes the time of people reading the general groups. Don't post about JavaScript; it's a different language. See comp.lang.javascript instead. -- "Yo' ideas need to be thinked befo' they are say'd" - Ian Lamb, age 3.5 http://www.cs.queensu.ca/~dalamb/ qucis->cs to reply (it's a long story...) ============================================================================== TOPIC: Threads and modal dialog behaviour question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7a5f146a46cb92ad ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 11:35 am From: Aloys Oberthür Babu Kalakrishnan wrote: > Aloys Oberthür wrote: > >> Babu Kalakrishnan wrote: >> >>> Aloys Oberthür wrote: >>> >>>> I have a question on modal dialogs in >>>> (non-event-dispatching)Threads. I do set a flag in the >>>> actionPerformed() method of a modal dialog and the object which >>>> displayed the dialog in the first place can question this flag after >>>> "returning" from show(). I would have expected this to be not timing >>>> dependant, but I see it is not which I do not understand >>>> >>>> >>>> that's the dialog in essence: >>>> >>>> class ModalerDialog extends JDialog implements ActionListener { >>>> boolean flagSuccessful = false; >>>> ... >>>> >>>> public void actionPerformed(ActionEvent aE) { >>>> String cmd = aEvt.getActionCommand(); >>>> >>>> if(cmd.equals("one")) { >>>> flagSuccessful = true; >>>> this.setVisible(false); >>>> } >>>> else if(cmd.equals("two")) { >>>> flagSuccessful = false; >>>> this.setVisible(false); >>>> } >>>> } >>>> >>>> public boolean isSuccessful() { >>>> return flagSuccessful; >>>> } >>>> } >>>> >>>> >>>> and that is the Thread launched within the actionPerformed()-method >>>> of a menu ActionListener (see // comments) >>>> >>>> Thread t = new Thread() { >>>> public void run() { >>>> >>>> ModalerDialog md = new ModalerDialog(owner, true); >>>> md.show(); >>> >>> >>> >>> >>> If "md" is really a modal dialog, I would expect this thread to stop >>> right here, and continue on to the next line only after the dialog has >>> been hidden / disposed off. That's how modal dialogs are expected to >>> behave. >>> >>>> >>>> boolean b = md.isSuccessful(); // now on "one" false >>>> try { >>>> Thread.sleep(250); >>>> } >>>> catch (InterruptedException e1) {} >>>> b = = md.isSuccessful(); // and now on "one" true ???? >>>> >>>> if(md.isSuccessful()) >>>> md.dispose(); >>>> else { >>>> md.dispose(); >>>> owner.showStartupDialog(); >>>> } >>>> } >>>> }; >>>> t.start(); >>>> >>> >>> Couldn't understand what your comments meant either. >>> >> >> It is true, that the Thread stops and displays the modal dialog. But >> although I first set the flag within the dialogs actionPerformed >> method and then set the dialog to not visible I get two results in the >> calling Thread depending on when I invove md.isSuccessful(). >> >> >> The comments referred to the actionCommand, I meant that the command >> "one" is the one, where successful is set to true in the >> actionPerformed() method above. >> > > OK - Check if the problem goes away if the variable flagSuccesful is > declared to be "volatile". (Or alternately declare the isSuccessful > method as synchronized). > > BK > > Unfortunately that does not help ;-( Aloys ============================================================================== TOPIC: [Applet Dev] Can JSO Object be called "remotely" ? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cf6f83ed2d3c9dfe ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 2:53 am From: [EMAIL PROTECTED] (Olivier aka Cypher) Hi gurus and fellows. I designed an pilot applet with can be seen at http://push.integration.euronext.com/Applet/index_raw2.htm This applet has no GUI in fact. It receive financial data (which are being pushed) and then update DOM element in the browser thanks to the "JSObject" library. Let's consider it acts as a "proxy" then. As is, it works under IE/Mozilla-like Browsers and both Microsoft JVM and Sun JVM. However this applet should be called from our corporate website (different domain name from the Url quoted above). Therefore I need to change the Applet's codebase from a relative one to an absolute one. That is : /Resources/ --> http://push.integration.euronext.com/Applet/Resources/ Same should apply to the "javascript include", of course (unless you save it locally too): /js/common.js --> http://push.integration.euronext.com/Applet/js/common.js It still work well under IE (Please save the file locally with the changes I mentioned earlier and you will see). So far so good !! However under Mozilla, the Javascript part is not triggered anymore by the applet. Is this a known bug / limitation ? Do you know any workaround ? Any help and tip much appreciated. Best regards. ============================================================================== TOPIC: Using the Command Pattern and Sockets? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5c34979f54b29d05 ============================================================================== == 1 of 1 == Date: Thurs, Dec 9 2004 10:54 am From: "Tilman Bohn" On Thu, 09 Dec 2004 04:41:16 +0000, Ken Adams wrote: > Yeah that makes sense, but my problem involved the last paragraph. So the > client say writes the Command object to the stream, and should it pass in an > object for the server to invoke the execute method against, or does the > server pass the object into the execute method and if so, how do you know > what type of object to pass in, since the Command objects no doubt can act > on different types of objects. Ok, I'm not sure if I completely understand your problem, so maybe this is completely beside the point for you. But anyway: The normal way is a no-arg execute(), but of course you can change that if you have a reason. The standard OO expectation would be that the Command object knows what other resources it needs to talk to to do its thing. If in your case the caller needs to specify other parameters for the Command to work with, you have to pass them in in _some_ way. One of the possible ways is as an arg to the execute() method. If what you call the client usually specifies other objects for the Command to use, it should call the relevant methods on the Command object before it gets sent. And you will then have to take care of that data in your marshalling and unmarshalling. After all, that's the whole point -- once you have the Command object, it should be able to execute(). Everything it needs from the originating side is supposed to already be encapsulated in it. Cheers, Tilman -- `Boy, life takes a long time to live...' -- Steven Wright ============================================================================== You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer" group. To post to this group, send email to [EMAIL PROTECTED] or visit http://groups-beta.google.com/group/comp.lang.java.programmer To unsubscribe from this group, send email to [EMAIL PROTECTED] To change the way you get mail from this group, visit: http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe To report abuse, send email explaining the problem to [EMAIL PROTECTED] ============================================================================== Google Groups: http://groups-beta.google.com
