comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Thread-question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5766e179910e25fa * Problem building jdk 1.3 from source for Windows - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/127339514e54c614 * Is instanceof dirty? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/395347a70489adef * Big Strings - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8d3a8b4e7997caff * java "anti-inliner" - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4bab43d82b18786 * microsoft java compatible - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2852c9279abda74 * Execute problem with JCreator - 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b864ab013f6b9085 * What is this? - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dc1b161a2a7049f7 * Does Java CGI Require Thread Management - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b2b0427cecdf178b * optimizeit: how to workaround/minimize wrong cput time in Object.wait() - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/567c06e241a81e28 * runtime.getRuntim().exec(somecmd) problem with linux - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a3f83ceedc3184b0 * Crystal Reports and Java - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/886626eebd3a3865 * Terminating a process tree - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d7dd1ce1cb22f1ca * EJB container manager transaction - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8ee70d0b01dce235 ========================================================================== TOPIC: Thread-question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5766e179910e25fa ========================================================================== == 1 of 1 == Date: Tues, Nov 9 2004 7:17 am From: "Thomas G. Marshall" <[EMAIL PROTECTED]> Yakov coughed up: > Ao <[EMAIL PROTECTED]> wrote in message > news:<[EMAIL PROTECTED]>... >> Hi everybody, >> >> when closing my program I would like to start a Thread which does >> some cleaning up in the background, but opf course before exiting I >> need to be sure, that this Thread has finished running... > > If you want to exit your app only after some code is finished, do not > even bother with threads. Just create another method with required > code, and the last line of your program should be a call of this > method. That is not going to work in general. His "code" that you refer to could easily just be firing up a pile of GUI and then do nothing more. Setting up the GUI is (usually) by nature non-blocking, this leaves no particular good time for that last line of his program to run. The other suggestions in this thread are better. -- http://www.allexperts.com is a nifty way to get an answer to just about /anything/. ========================================================================== TOPIC: Problem building jdk 1.3 from source for Windows http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/127339514e54c614 ========================================================================== == 1 of 2 == Date: Tues, Nov 9 2004 7:19 am From: Thomas Fritsch <[EMAIL PROTECTED]> Ulas Ergin wrote: > Hi all, > I have downloaded the source for jdk 1.3 from Sun's site.During > compilation in Visual C++ 6.0 SP 6 I am facing a trouble. > > Some of tje source files (to name one > \src\share\javavm\include\javastring.h) includes java_lang_String.h. > > But the source does not contain any java_lang_String.h. > On the other hand java_lang_String.h comes with standard jdk > distribution in the include-old folder with contains deprecated JNI > headers. > > What is the problem here? Why does the jdk source reference > java_lang_String.h but it does not include it? Don't know the details about JNI, but perhaps *you* have to generate these h-files from the class-files. For example: javah java.lang.String or javah -jni java.lang.String (just a guess...) > > any help is appreciated, > thx -- "Thomas:Fritsch$ops:de".replace(':','.').replace('$','@') == 2 of 2 == Date: Tues, Nov 9 2004 7:47 am From: "Ann" <[EMAIL PROTECTED]> "Ulas Ergin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all, > I have downloaded the source for jdk 1.3 from Sun's site.During > compilation in Visual C++ 6.0 SP 6 I am facing a trouble. > > Some of tje source files (to name one > \src\share\javavm\include\javastring.h) includes java_lang_String.h. > > But the source does not contain any java_lang_String.h. > On the other hand java_lang_String.h comes with standard jdk > distribution in the include-old folder with contains deprecated JNI > headers. > > What is the problem here? Why does the jdk source reference > java_lang_String.h but it does not include it? > > any help is appreciated, > thx My view of compiling stuff for windows when a binary is available: Are you nuts? ========================================================================== TOPIC: Is instanceof dirty? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/395347a70489adef ========================================================================== == 1 of 1 == Date: Tues, Nov 9 2004 7:31 am From: "xarax" <[EMAIL PROTECTED]> "Chris Uppal" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > DeMarcus wrote: > > > What's the common opinion about using the java keyword > > instanceof? > > I don't disagree with the previous replies that I've seen, but I wanted to give > a slightly different spin to the answer. > > Think of it this way: the system (Java's semantics and OO in general) is > designed so that objects are responsible for their own behaviour. That's to > say that it's /their/ responsibility to know "what they are" and what they > should do in any specific circumstance. If you use instanceof then you are > cutting them out of the loop. In effect you are saying, "no, I don't care what > you think, I'm going to do this /my/ way". > > Now that's fine if you know what you are doing and have a good reason. But you > are also throwing away the modularity, flexibility, comprehensibility, and > maintainability that were the point of using OO in the first place. > > You can think of 'instanceof' as a specific kind of reflection. Other examples > of reflection are the facilities in java.lang.reflect for looking at what > methods and fields are available, and the use of finalize() to reflect on an > object's lifetime. These features allow you more power and control over the > way the system works, but at the cost that /you/ have taken over responsibility > for some aspect of the operation that the system would otherwise look after for > you. Reflection in general is something that "ordinary" programs don't, and > shouldn't, make much use of. (Although, as Chris Smith noted, it does depend > on how dynamic a programming environment / language you are working with[*]) > In general, even if you do need to use reflection (and 'instanceof' > specifically) to make some design work, then it won't be as ad-hoc hacks > scattered randomly around the system. You'd be able to look at the design in > advance and say (after some thought) "we'll need to use reflection <here> and > <here>, there's no need for it anywhere else". > > And I think that's the point: if you are just scattering 'instanceof' around in > an arbitrary way (if a reader can't look at what a method does and reliably > guess whether you'd use 'instanceof' before reading your code) then you are > almost certainly creating an ugly mess of hacks. > > BTW, there's nothing /inherently/ wrong with slimy hacks. Sometimes you can > use a well-placed hack to gather all the ugliness of (part of) a system into > one place and hide it where it doesn't affect everything else. You'll be able > to recognise such uses quite easily since there will be a long comment > apologising for the hack, and explaining why it's better than the alternatives > in this case. /snip/ I agree. Using "instanceof" is similar to using a switch block with some kind of "type code" thing that distinguishes the actual type. The general rule of OOP is that such constructs should be replaced with polymorphism where possible. In the case of external non-OO data, a switch block is necessary for creating the initial object with an appropriate subtype. I've used "instanceof" mostly in places where I was too lazy to do it the right way. For example, an ArrayList that has both JPanel and JLabel instances, I would use "instanceof" to distinguish and downcast the next instance that I pulled from the ArrayList. It was simple, it worked, and the ArrayList was very private. There was no way that the "instanceof" usage could spread through-out the application. For a more flexible approach, I use something like this: ========================================= public class Fubar { public void doGork(final Gork gork) { /* I want to do something with a Gork that depends on the actual subtype of Gork. */ gork.invoke(this); } public void doSomething(final Snafu snafu) { /* Snafu is a subtype of Gork. */ } public void doSomething(final Gecko gecko) { /* Gecko is a subtype of Gork. */ } } public abstract class Gork { public abstract void invoke(Fubar fubar); } public class Snafu extends Gork { public void invoke(final Fubar fubar) { /* calls Fubar.doSomething(Snafu) */ fubar.doSomething(this); } } public class Gecko extends Gork { public void invoke(final Fubar fubar) { /* calls Fubar.doSomething(Gecko) */ fubar.doSomething(this); } } ========================================= This is a form of reflection that uses overloading to distinguish the actual subtype of Gork that was passed to Fubar.doGork(Gork). Since Fubar must know all of the subtypes of Gorko (which it must know anyway when using instanceof), this technique avoids instanceof and achieves the same effect of distinguishing the actual subtype of Gork on behalf of Fubar.doGork(Gork). A little imagination can extend this technique to many subtypes of Gork by just adding the appropriate overloaded "doSomething" method to Fubar, and defining the new subtype of Gork with the "invoke(Fubar)" method. Notice that even though the "invoke" methods in each of the subclasses are textually the same, their effect is very different from each due to the usage of "this" in the method call, which distinguishes which overloaded "doSomething" method is called. You would not want to refactor these methods to the parent abstract class (do you see why?). This is a very clean usage of polymorphism that avoids "instanceof" and clearly separates the work that Fubar.doGork(Gork) wants to perform on the actual subtype of Gork. -- ---------------------------- Jeffrey D. Smith Farsight Systems Corporation 24 BURLINGTON DRIVE LONGMONT, CO 80501-6906 http://www.farsight-systems.com z/Debug debugs your Systems/C programs running on IBM z/OS for FREE! ========================================================================== TOPIC: Big Strings http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8d3a8b4e7997caff ========================================================================== == 1 of 3 == Date: Tues, Nov 9 2004 7:39 am From: "Virgil Green" <[EMAIL PROTECTED]> "Ann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > "Randy Dizitser" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > I have a string thats larger then the maximum size that the String > > class can accomodate. Is there a way to still store my string as one > > string? > > same way you put 6 elephants in a volkswagen > (3 in the front, 3 in the back) ;-) 3 in the back, 2 in the front, and one in the glove box. == 2 of 3 == Date: Tues, Nov 9 2004 7:49 am From: "Ann" <[EMAIL PROTECTED]> "Virgil Green" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Ann" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > > "Randy Dizitser" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > I have a string thats larger then the maximum size that the String > > > class can accomodate. Is there a way to still store my string as one > > > string? > > > > same way you put 6 elephants in a volkswagen > > (3 in the front, 3 in the back) ;-) > > 3 in the back, 2 in the front, and one in the glove box. > I forgot you need room for the driver, tnx. == 3 of 3 == Date: Tues, Nov 9 2004 8:15 am From: [EMAIL PROTECTED] (Greg Smith) [EMAIL PROTECTED] (Randy Dizitser) wrote in message news:<[EMAIL PROTECTED]>... > I have a string thats larger then the maximum size that the String > class can accomodate. Is there a way to still store my string as one > string? I have stored megabytes in a string. how large is this string? ========================================================================== TOPIC: java "anti-inliner" http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4bab43d82b18786 ========================================================================== == 1 of 1 == Date: Tues, Nov 9 2004 7:44 am From: "Ann" <[EMAIL PROTECTED]> "taylorius" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Greetings, > > Has anybody here heard of a program that will take java code, identify > duplicated (or parameterizable) fragments of the program (probably at > the bytecode level) and convert them into a function and calls to it. > > I suppose this runs somewhat counter to efforts aimed at program > specialization, but I thought it may be something the obfuscation / > code size reduction community may have toyed with. Is it even > feasible? > > Regards > > > Matt Taylor I used simian a few times, but you have to make the code changes yourself. I would not want a program changing my source without telling me where etc. first. (Especially when you consider small sections like a few lines.) >From the index.html --- Simian (Similarity Analyser) identifies duplication in Java, C#, C, C++, COBOL, Ruby, JSP, ASP, HTML, XML, Visual Basic source code and even plain text files. In fact, simian can be used on any human readable files such as ini files, deployment descriptors, you name it. ========================================================================== TOPIC: microsoft java compatible http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2852c9279abda74 ========================================================================== == 1 of 3 == Date: Tues, Nov 9 2004 7:48 am From: "Sam" <[EMAIL PROTECTED]> How can I compile an applet so that it can be run on machines that only have the Microsoft Java Virtual Machine (MSJVM) ? Thanks, Sam == 2 of 3 == Date: Tues, Nov 9 2004 7:52 am From: Michael Borgwardt <[EMAIL PROTECTED]> Sam wrote: > How can I compile an applet so that it can be run on machines that only have > the Microsoft Java Virtual Machine (MSJVM) ? Use the -target 1.1 and -bootclasspath options - the latter pointing at a set of classes corresponding to the 1.1.4 Java API. == 3 of 3 == Date: Tues, Nov 9 2004 8:09 am From: Andrew Thompson <[EMAIL PROTECTED]> On Tue, 09 Nov 2004 16:52:45 +0100, Michael Borgwardt wrote: > Sam wrote: > >> How can I compile an applet so that it can be run on machines that only have >> the Microsoft Java Virtual Machine (MSJVM) ? > > Use the -target 1.1 and -bootclasspath options - the latter pointing at a set > of > classes corresponding to the 1.1.4 Java API. If you are confident that you are only referencing 1.1(.4) classes and members, the -bootclasspath option can be dropped. (It is mighty handy to *check* though) Do you have an IE with the MSVM? <http://www.physci.org/pc/property.jsp?prop=java.vendor> If so, you can find your MSVM class zips here.. <http://www.physci.org/ms/msclassfile.jsp> HTH -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ========================================================================== TOPIC: Execute problem with JCreator http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b864ab013f6b9085 ========================================================================== == 1 of 4 == Date: Tues, Nov 9 2004 8:12 am From: "Mark K" <[EMAIL PROTECTED]> I have a simple test program that was copied from the book. It compiles fine but when I try to execute it I get a command prompt that runs some GE2001.exe which shows the help for trying to execute the .JAVA program. == 2 of 4 == Date: Tues, Nov 9 2004 8:36 am From: Andrew Thompson <[EMAIL PROTECTED]> On Tue, 09 Nov 2004 16:12:40 GMT, Mark K wrote: > I have a simple .. Questions from people starting Java are best dealt with on a different group described here.. <http://www.physci.org/codes/javafaq.jsp#cljh> > ...test program .. Where? <http://www.physci.org/codes/sscce.jsp> >...that was copied from the book. (Looks around) ..What book? The Koran? >..It compiles fine .. Define 'fine'? Exactly how do you compile it, from the command line? If so, what is the exact command and output? >..but when I try to execute it I get a command prompt that runs some > GE2001.exe which shows the help for trying to execute the .JAVA program. That does not makes sense, since you can a) compile a .java source code or b) execute/run a .class/.jar Which brings me to.. <http://www.physci.org/codes/javafaq.jsp#exact> followed by. *Always* copy/paste output, otherwise you are wasting everybodys time and bandwidth. -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane == 3 of 4 == Date: Tues, Nov 9 2004 8:47 am From: "Ann" <[EMAIL PROTECTED]> "Mark K" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have a simple test program that was copied from the book. It compiles > fine but when I try to execute it I get a command prompt that runs some > GE2001.exe which shows the help for trying to execute the .JAVA program. First, try reading the "...shows the help for trying to execute..." Then you might look at "JCreator.chm" which is in the same directory as "JCreator.exe" and "GE2001.exe" == 4 of 4 == Date: Tues, Nov 9 2004 8:54 am From: Andrew Thompson <[EMAIL PROTECTED]> On Tue, 09 Nov 2004 16:47:29 GMT, Ann wrote: > "Mark K" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> I have a simple test program that was copied from the book. It compiles >> fine but when I try to execute it I get a command prompt that runs some >> GE2001.exe which shows the help for trying to execute the .JAVA program. > > First, try reading the "...shows the help for trying to execute..." Read the documentation? Has the world gone *mad*? The OP sounds like he might also benefit from a still *more* radical strategy.. <http://www.xdweb.net/~dibblego/java/faq/answers.html#Q34> -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ========================================================================== TOPIC: What is this? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dc1b161a2a7049f7 ========================================================================== == 1 of 3 == Date: Tues, Nov 9 2004 8:26 am From: "stev<nospam>uote_ehncd.com" <"stev<nospam>uote_ehncd.com"> Hey, everyone, I have just been perusing the source code for hibernate, and at the top I see something like this.... //$Id: MessageHelper.java,v 1.9 2004/06/04 05:43:47 steveebersole Exp $ It seems like source code integration with version control. I would like to see more detail. Thanks == 2 of 3 == Date: Tues, Nov 9 2004 8:31 am From: Michael Borgwardt <[EMAIL PROTECTED]> stev<nospam>uote_ehncd.com wrote: > Hey, everyone, I have just been perusing the source code for hibernate, > and at the top I see something like this.... > > //$Id: MessageHelper.java,v 1.9 2004/06/04 05:43:47 steveebersole Exp $ > > It seems like source code integration with version control. I would > like to see more detail. That's just a tag that is automatically updated by CVS with information about the file name, version, last change and who did the last change. To get more information such as the complete version history, you have to access the CVS server directly. == 3 of 3 == Date: Tues, Nov 9 2004 8:39 am From: Thomas Fritsch <[EMAIL PROTECTED]> stevuote_ehncd.com wrote: > Hey, everyone, I have just been perusing the source code for hibernate, > and at the top I see something like this.... > > //$Id: MessageHelper.java,v 1.9 2004/06/04 05:43:47 steveebersole Exp $ > > It seems like source code integration with version control. I would > like to see more detail. > > Thanks It is described in http://www.rons.net.cn/htp/cvs/cvs_12.html -- "Thomas:Fritsch$ops:de".replace(':','.').replace('$','@') ========================================================================== TOPIC: Does Java CGI Require Thread Management http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b2b0427cecdf178b ========================================================================== == 1 of 2 == Date: Tues, Nov 9 2004 8:42 am From: [EMAIL PROTECTED] (JR) Hi. I have about about two dozens CGI scripts written in Perl that I need to convert to Java. The machine on which these scripts reside doesn't support servlets, so I'm stuck with converting basic CGI from one language to another. With any CGI, regardless of language, is it necessary to manage threads, or is that taken care of by the server handling the request? My limited understanding is that a CGI request will spawn a new process, and create a unique thread for that process. Also, I'd like one day to be able to move the Java CGI programs that I will write as part of the above conversion to a machine that does support servlets. I'd appreciate any recommendations as to references that clearly explain how to handle the multi-threaded capability of servlets. My only experience with threads so far is work from a chapter of Ivor Horton's Beginning Java 2. The concepts seem pretty difficult to grasp, and I'm not sure how I could apply them to an a servlet that may have from x to y number of possible threads. It would be awesome if there were a thread manager class that handled threads for the programmer, but I'm probably missing the point of threads to hope for that. Thanks. JR == 2 of 2 == Date: Tues, Nov 9 2004 8:54 am From: Michael Borgwardt <[EMAIL PROTECTED]> JR wrote: > Hi. I have about about two dozens CGI scripts written in Perl that I > need to convert to Java. The machine on which these scripts reside > doesn't support servlets, so I'm stuck with converting basic CGI from > one language to another. With any CGI, regardless of language, is it > necessary to manage threads, or is that taken care of by the server > handling the request? My limited understanding is that a CGI request > will spawn a new process, and create a unique thread for that process. This is indeed the case, and the reason why you will experience HORRIBLE performace if you use Java like that. Your server would have to start a separate JVM process for each request, and starting up a JVM takes much more time and memory than the perl interpreter. My advice: stick with Perl until you can run servlets. > Also, I'd like one day to be able to move the Java CGI programs that I > will write as part of the above conversion to a machine that does > support servlets. I'd appreciate any recommendations as to references > that clearly explain how to handle the multi-threaded capability of > servlets. My only experience with threads so far is work from a > chapter of Ivor Horton's Beginning Java 2. The concepts seem pretty > chapter of Ivor Horton's Beginning Java 2. The concepts seem pretty > difficult to grasp, and I'm not sure how I could apply them to an a > servlet that may have from x to y number of possible threads. It > would be awesome if there were a thread manager class that handled > threads for the programmer, but I'm probably missing the point of > threads to hope for that. Actually, the only thing you need to know about threads when programming servlets is: don't use them. The servlet container will act sort of like your "thread manager", i.e. it will automatically run each request in a separate thread(possibly using a pool). ========================================================================== TOPIC: optimizeit: how to workaround/minimize wrong cput time in Object.wait() http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/567c06e241a81e28 ========================================================================== == 1 of 1 == Date: Tues, Nov 9 2004 8:44 am From: "Robert Klemme" <[EMAIL PROTECTED]> "NOBODY" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > > Or it means, there are too many invocations of wait(). > > You'd probably then want to switch from notifyAll() to notify(). Or > > you have a problem on the notifier side, for example with a farmer > > worker scenario where the farmer is too slow putting tasks into the > > task queue; then workers will starve and will wait most of the time. > > I already have separated writers semaphore and readers semaphore. > The writer notify() one blocked reader, reader notify() one blocked > writer. Works great. That was the fix I tried. But didn't change much the > profile. > > > >> it. What I want to determine is the real wait() %cpu due to real > >> contention to reaquire the monitor. > > > > So you don't want CPU time but wall clock time. > > I never want clock time. I already have monitored throughput of my code. Then are you satisfied with the throughput? If yes, why do you bother with the 70%? > A stackframe could be on wait() but actually the thread is done waiting > (waited, in JVMPI language) and tries to acquire the monitor. > > Would that part will be shown as cpu or not? Not documented. I supposed > yes because that would explain the 70% of time in wait() caused by > contention. I agree the cpu is not working for that thread though and I > shouldn't care, but... I did a small test where I increased overall wait time by sleeping before the notify and wait didn't even show up in the profiler results (with -Xrunhprof). Probably testing another profiler is best you can do at the moment. > But excessive contention (like you mentionned through notifyAll()) is > only detectable by guessing if the invocation count is to high, which > requires intrumentation mode, hence give a very biased result. > > So I don't know if I have high contention or if it is just a rounding > error! That's the whole problem. Since this seems to affect only one place in the code, did you consider instrumenting the code with measurements of your own? You could have a wait counter and a wait time counter and thus determine average wait time. Also, you might want to check average queue size (I assume you have a queue to transport the tasks or whatever it is). > I was planning to try other profilers. I guess this is inevitable. I'd start with "java -Xrunhprof". For me this gives quite good results and it's easy to use. You can use HPJmeter to view values or a tool named PerfAnal which you can find on sun's website. Both are free. Good luck! robert ========================================================================== TOPIC: runtime.getRuntim().exec(somecmd) problem with linux http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a3f83ceedc3184b0 ========================================================================== == 1 of 2 == Date: Tues, Nov 9 2004 8:46 am From: [EMAIL PROTECTED] (wex) I apologize for not giving more accurate code but I thought it was easier with the simplistic example which I did test. But anyways the "real code". My program reads in a properties file that contains commands. These commands vary based on the type of install client/server, standalone etc. The command I am having a problem with, starts a hsql database. When the software starts up a function that starts all these different processes is run. The code i use to start it is: public void startProcess(String cmd) { try { Runtime rt = Runtime.getRuntime(); Process process = rt.exec(cmd); } catch (Exception e) {// handle any error app.handleException(e,"ProcessMgr.startProcess",App.ERR_LOG_DISK|App.ERR_STACK); } } The properties are loaded: props = new java.util.Properties(defaults); //load the properties from disk try { props.load(new java.io.FileInputStream(appPath + appPropertyFile)); if ( ((String)props.get("mode")).length() == 0) { // set from the defaults and store properties props = (java.util.Properties)defaults.clone(); props.store(new java.io.FileOutputStream(appPath + appPropertyFile),"Radiation Oncology Application Parameters"); } setAppProperties();//this replaces the <appPath> and <fileSep> variables properly } catch ( java.io.IOException ex) { // handle problem with loading application properties handleException(ex,"Creating application properties","App.loadAppProperties", The properties file looks like this: db_start=java -Xms64m -Xmx128m -cp <appPath>lib<fileSep>hsqldb.jar org.hsqldb.Server -port 9001 -database <appPath>data<fileSep>med -silent false -trace false <appPath> is replaced with the path to the application and the <fileSep> is replaced with the platform specific file separator. Now I have bypassed all this in my testing and tried just executing the command: String cmd ="java -Xms64m -Xmx128m -cp /home/ryan/documents/program files/hsqldb.jar org.hsqldb.Server -port 9001 -database /home/ryan/documents/program files/data/med -silent false -trace false"; Runtime rt = Runtime.getRuntime(); Process process = rt.exec(cmd); And I have of course tried every variation of quotes and backslashes surrounding the path(notice the space between "program files"): cmd ="java -Xms64m -Xmx128m -cp \"/home/ryan/documents/program files/hsqldb.jar\" org.hsqldb.Server -port 9001 -database \"/home/ryan/documents/program files/data/med\" -silent false -trace false"; cmd ="java -Xms64m -Xmx128m -cp /home/ryan/documents/program\\ files/hsqldb.jar org.hsqldb.Server -port 9001 -database /home/ryan/documents/program\\ files/data/med\" -silent false -trace false"; . . etc I have tried encapsulating the whole command in a string array and passing that off to rt.exec with various quotes, backslashes, etc. String[] cmds = {cmd}; Runtime rt = Runtime.getRuntime(); Process process = rt.exec(cmds); And of course all of this works fine when there is no space. It also works completely fine in windows by just putting quotes around the paths. So I hope this contains some better info for you. Really appreciate everyone trying to help. -ryan == 2 of 2 == Date: Tues, Nov 9 2004 8:58 am From: Andrew Thompson <[EMAIL PROTECTED]> On 9 Nov 2004 08:46:24 -0800, wex wrote: > The code i use to start it is: Sorry wex, not interested. Not until you show some sign of paying close attention to advice. Could you read the link on preparing examples more carefully? <http://www.physci.org/codes/sscce.jsp> Your code is not an SSCCE. -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ========================================================================== TOPIC: Crystal Reports and Java http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/886626eebd3a3865 ========================================================================== == 1 of 1 == Date: Tues, Nov 9 2004 9:54 am From: "Alex Molochnikov" <[EMAIL PROTECTED]> It's a pity, since the Java-based solution like Scribe could be deployed cross-platform. Anyway, good luck with your struggle against .NET/Crystal. Alex. "Gleb" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Looks not bad, but unfortunately we've already created system on .NET, > sory for the M-word in this discussion :). And now we need same or > near the same functioanality on Java, primarily for Linux. That's why > we are interesting in Crystal.Although, apparenntly Crystal for pure > Java is not so good as for .NET :(. ========================================================================== TOPIC: Terminating a process tree http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d7dd1ce1cb22f1ca ========================================================================== == 1 of 1 == Date: Tues, Nov 9 2004 9:56 am From: "John C. Bollinger" <[EMAIL PROTECTED]> Wayne Marrison wrote: > "John C. Bollinger" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] [...] >>All you need to do to start a Java program is invoke the static main() >>method of its main class. You can do that from any Java code: >> >>void startExternalApp(String[] args) { >> ExternalApp.main(args); >>} > > > ExternalApp is imported somehow? In that example, yes. The external app's jar would need to be in the launcher's classpath, and you would need to import the package.name.ExternalApp class into the launcher. Do note that that is a compile-time name resolution thing: it will end up putting the fully-qualified name of the ExternalApp class into your launcher class, but it does not bring in any of its code. Note also that ClassLoader-based solution is completely different in this regard: in that case you want to _avoid_ having the external app's classes accessible via your launcher app's own ClassLoader; they should only be accessible via the ClassLoader(s) that you configure for the external app. >>If you want to make the external app use its own ClassLoader (so as to >>segregate its classes from your launcher app's own, and also from those of >>any other instance your launcher starts, then you would need to get a bit >>fancier. You would instantiate the ClassLoader (probably an instance of >>URLClassLoader; make sure it points to a suitable parent ClassLoader) use >>it to load the correct Class, then look up the correct main() Method in >>the Class object and invoke it. The Class and Method classes are part of >>the Java "Reflection" API -- you should generally avoid them unless you >>need them, but this is a case where you would need them. >> >>You can take one more step and assign the external app to its own thread. >>The easiest way to do this would be something like: >> >>Thread startExternalAppInThread(final String[] args) { >> ClassLoader cl = new URLClassLoader(/* your args here*/); >> Class appClass = cl.findClass("fully.qualified.name"); >> final Method mainMethod = >> appClass.getMethod("main", new Class[] {args.getClass()}); >> >> return new Thread() { >> public void run() { >> mainMethod.invoke(null, new Object[] {args}); >> } >> } >>} >> > > It would appear the idea of ClassLoading is a good one (still lots of docs > to read to find out how to make my situation fit), however my primary > questions are: > > The external application is a console based java app, and is started from > this command line: > "java -cp C:/xxxxxx/lib/xxxxxxxxxx23.jar com.xxxxxxxx.remote.xxx XXX" (names > changed to protect the innocent). Does this still fit the ClassLoader > model? Java uses a ClassLoader to load classes no matter what. In many cases you don't have to do anything special about it to get what you want; Java sets up a suitable ClassLoader for you and uses it to load your classes. We're discussing using ClassLoaders to achieve somewhat fancier effects that would require explicit use of a ClassLoader in your code. The short answer is that every working Java application necessarily fits the ClassLoader model because that's the _only_ Java-compliant way to run it. > Can I still perform the capture and redirection of the relevant i/o streams > in order to control the application? Yes (see java.lang.System.setIn(), etc.). However, a JVM has only one standard input stream, one standard output stream, and one standard error stream, so if that's the only way to talk to the application then your own application must forgo using those streams while the external app is using them. (And you wouldn't be able to simultaneously run multiple instances of the external app.) > If so, would how would the following code change to reflect it? > (ErrorStreamReader,StreamReader and StreamWriter are all threads for the > relevant streams). Keep in mind that bringing the external app into your own app, you reverse the sense of its streams. I'm guessing a bit on your StreamReader, etc. classes, but here goes: > ============================================ > // any error message? > error = new ErrorStreamReader(proc.getErrorStream(), "ERROR", running); // errorOut = new PipedOutputStream(); errorOutSink = new PipedInputStream(errorOut); System.setErr(new PrintStream(errorOut)); error = new ErrorStreamReader(errorOutSink, "ERROR", running); > this should be picked up by the log reader > > // any output? > pin = new PipedInputStream(); // open input pipe > pout = new PipedOutputStream(pin); // open output pipe and bind to input > pipe > > dis = new DataInputStream(pin); > > reader = new StreamReader(proc.getInputStream(), pout , "OUTPUT", running); procOut = new PipedOutputStream(); procOutSink = new PipedInputStream(procOut); System.setOut(new PrintStream(procOut)); dis = new DataInputStream(procOutSink); /* Then read the external app's output via "dis". Comment: Do you really need a DataInputStream here? Is the external app really writing raw Java primitives? */ > // capture output stream, and send to pout > > // prepare writer > writer = new StreamWriter(proc.getOutputStream(),running); I'm not certain of the details of StreamWriter's operation, but you probably want to do something based on this: procIn = new PipedInputStream(); procInSource = new PipedOutputStream(procIn); System.setIn(procIn); /* (Then write to procInSource to send data to the external app's standard input.) */ > ========================================== Note that in that example it may not be safe to write to "procIn" and read from "dis" in the same thread. That is not materially different from the situation in your own code, however, where it is not safe to write to "writer" and read from "dis" in the same thread. Even though you are using separate StreamWriters and StreamReaders, you are sending the external proc's output (read from the Process' InputStream) through a pipe, which can block if the pipe's internal buffer fills. The whole StreamReader bit is therefore kind of pointless for that part -- it introduces an additional thread that doesn't materially benefit you. The thread that is handling each stream needs to do the appropriate thing with it, more or less on its own. It must not be possible for any of them to block on action by any of the others. > Is there not a 3rd party class that perform this activity for me as there > seems to be a lot to learn and not a lot of time to learn it in? Perhaps > the hurry that I am in is half my problem .. The ClassLoading bit? I wouldn't be surprised to hear that there is one, but I'm not specifically aware of any. An external process manager? I am fairly certain that you could find such a thing, perhaps even for free, but again, I don't have a link to give you. John Bollinger [EMAIL PROTECTED] ========================================================================== TOPIC: EJB container manager transaction http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8ee70d0b01dce235 ========================================================================== == 1 of 1 == Date: Tues, Nov 9 2004 9:57 am From: "Grzegorz Trafny" <[EMAIL PROTECTED]> "ShadowMan" wrote: > I've already tried this ....but > > 1. I don't see any EJBContext reference...rather I see SessionContext > (that is an extension)... Did you see quotations? I assumed that you will understand metaphore at once :) > 2. in the auto-generated javadoc for this method ....I've read > > /** > * This method is called with no transaction context. > * > */ > > so...there is something that I miss....I would the container manages > transactions... Naturally, some methods aren't called by container in "full context" (including transaction context), especially when container begins creation of ejb object. But this matter DO NOT influence setting class variable "context" and futher taking advantage of this variable when ejb object is completely initialized. So I don't see any problem. Greetings GT ======================================================================= 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
