comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Tomcat responce time 10-200 seconds once in a while - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/eff0206fed26be06 * Implementing Legacy Byte Packed Message Interfaces - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c7a17f0bc392a7f7 * JavaMail - SMTP - Exchange Server Authentication - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e33c67570bd15c77 * Absolute path / creating FileWriter-object - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1a379ecf95903690 * GIS co-ordinates - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/610f3c6489d3730b * getting the disk absolute path of a web-app - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cbdd00f8c8b7f37a * newbie - jdbc Problem - 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3b61df05d633ffba * Performance of null tests? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e1febd5672a2f269 * 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 * How do you cast to array? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/884dee2def4bbb47 * ant newbie question - 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/37ab639829111df3 * Yahoo! Lies: You can play Capture in Linux - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/273970295076400c * Reading Stacktrace in J2ME? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c1df4fa6425d1c5 * A Java "interface" declaration does not allow a constructor to be specified in it ... - 5 messages, 5 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a241d06ab76f90b8 ========================================================================== TOPIC: Tomcat responce time 10-200 seconds once in a while http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/eff0206fed26be06 ========================================================================== == 1 of 1 == Date: Sat, Nov 6 2004 11:27 am From: Roman Zhovtulya <[EMAIL PROTECTED]> Maz Rashid wrote: > Have you considered, that this might be the garbage collector, that takes > that long? > regards > Maz > thanks a lot for the reply. how do I check if garbage collector really is the problem? What can I do to decrease the delay? How do I make garbage collector run more often? Thanks a lot, Roman ========================================================================== TOPIC: Implementing Legacy Byte Packed Message Interfaces http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c7a17f0bc392a7f7 ========================================================================== == 1 of 3 == Date: Sat, Nov 6 2004 11:44 am From: [EMAIL PROTECTED] (Ken) "Chris Uppal" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > > In essence you will have to do exactly what you would do if you were > interfacing with those legacy systems using C. Find out how the compiler for > the legacy code lays out the data in memory, read the data in as some > primitive > type (byte or int seems natural), and define appropriate bitmasks that overlay > the layout to extract the data you want. How do you make bitmasks in Java, especially ones that will handle these non-byte boundary bit fields? Thanks, Ken == 2 of 3 == Date: Sat, Nov 6 2004 1:59 pm From: "xarax" <[EMAIL PROTECTED]> "Ken" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Chris Uppal" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > > > > > In essence you will have to do exactly what you would do if you were > > interfacing with those legacy systems using C. Find out how the compiler for > > the legacy code lays out the data in memory, read the data in as some primitive > > type (byte or int seems natural), and define appropriate bitmasks that overlay > > the layout to extract the data you want. > > How do you make bitmasks in Java, especially ones that will handle > these non-byte boundary bit fields? Use the bitwise operators just like in C for AND'ing and OR'ing, and use shifting. == 3 of 3 == Date: Sun, Nov 7 2004 1:54 am From: "Chris Uppal" <[EMAIL PROTECTED]> Chris wrote: > Thanks for feedback. It is unfortunate that the C Structs do not just > support primitive types. That's a constraint placed upon us by the > legacy device message interface. My initial thought was to leverage > the C based JNI layer to overlay the input bag of bytes using the C > Struct, extract the fields (leveraging the underlying C code to > minipulate the bits), and then retain in the target Java Object via > the JNI calls. Is the run-time cost of this approach less/more > efficient then doing all the bit minipulation in Java via home-grown > conversion utilities ??? Without knowing the details of you application, I can only make guesses from a distance. However... If you think about it, accessing these fields will require bit-twiddling (masking , shifting, etc) to decode them however you do it, the only difference is whether the relevant instructions are generated automatically by the C compiler, or semi-automatically by the JVM's JITer following instructions provided by you in Java. There's not likely to be a huge amount of difference between the two. So the additional overhead of JNI is only justified if either (a) you are already using JNI to get the data and the only question is whether to translate it to a more portable format before or after passing it across the JNI boundary, or (b) .... Well, actually, I can't think of a (b). JNI is complicated and difficult to maintain (if only because it has a different build-path, and requires skills that not all Java programmers have). So it's hard to imagine a situation where the (comparative) slowness and complexity of JNI would be better than doing a little bit-twiddling in Java. I suppose if you had vast numbers of these structures to decode, and they kept changing (i.e. the "legacy" code isn't really legacy, but is under active development and you can't persuade the developers that changing externally defined structures is a /bad/ idea....). But even then, I think there would be better ways of handing it (hitting the other developers of their collective heads with a brick would be a good start ;-) as would be sending them on a good course for a refresher in the dos-and-don'ts of C programming). Note that the layout of structures and bitfields in memory is dependent on the compiler, and particularly on the /settings/ of the compiler -- and there's always the risk that the settings required for compiling JNI code would conflict the settings that your legacy code assumes. (Whether that would /actually/ be a problem is impossible for me to guess.) -- chris ========================================================================== TOPIC: JavaMail - SMTP - Exchange Server Authentication http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e33c67570bd15c77 ========================================================================== == 1 of 1 == Date: Sat, Nov 6 2004 12:10 pm From: Rico <[EMAIL PROTECTED]> >From the JavaMail docs: ------------------------------------------------------------------ public void connect(java.lang.String host, java.lang.String user, java.lang.String password) throws MessagingException Throws: AuthenticationFailedException - for authentication failures MessagingException - for other failures IllegalStateException - if the service is already connected ------------------------------------------------------------------ I call this method with a known wrong password for that host and username, there is no exception thrown at all. Have I misread something? The server is an Exchange Server that ThunderBird and MS Outlook and Outlook Express have no problem using as SMTP server to send emails out to wherever. JavaMail sends the email through to only addresses from the same domain as the SMTP server (set to allow relaying upon successful authentication), regardless of authentication. Am I missing something? Rico. ========================================================================== TOPIC: Absolute path / creating FileWriter-object http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1a379ecf95903690 ========================================================================== == 1 of 2 == Date: Sat, Nov 6 2004 11:20 am From: Oscar kind <[EMAIL PROTECTED]> Jesper Sahner <[EMAIL PROTECTED]> wrote: > FileWriter file = new FileWriter("myfile.txt"); > > The file "myfile.txt" is then placed in the directory from where Java > is called, in my setup C:\Program Files\NetBeans 3.6 > > However I want to place the file "myfile.txt" in the same directory > (package) as the .class-file in which the FileWriter-object is > created. > > How do I do this? You don't. At least not in a clean way. You may try to find the part of the classpath where your class resides (for example "."), and select the correct directory based on the package name. This "solution" will come crashing down however, if you: - package the application in a .jar file, or - use an URLClassloader, or - use any other method where classes are not available in an unpacked directory structure. -- Oscar Kind http://home.hccnet.nl/okind/ Software Developer for contact information, see website PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2 == 2 of 2 == Date: Sat, Nov 6 2004 7:30 pm From: Andrew Thompson <[EMAIL PROTECTED]> On 6 Nov 2004 10:46:38 -0800, Jesper Sahner wrote: > However I want to place the file "myfile.txt" in the same directory > (package) as the .class-file in which the FileWriter-object is > created. > > How do I do this? *Why* do you want to do that? (See Oscar's answer) It is generally better to put the file inside a known location (sub directroy, whatever..) of "user.home". -- 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: GIS co-ordinates http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/610f3c6489d3730b ========================================================================== == 1 of 1 == Date: Sat, Nov 6 2004 11:24 am From: Oscar kind <[EMAIL PROTECTED]> Roubles <[EMAIL PROTECTED]> wrote: > If I am given a jpg of a map and a number of GIS co-ordinates, any > ideas on how I can go about plotting those coordinates on the jpg ? > > Further, if I had to draw a line between two GIS co-ordinates - any > ideas on how to do that ? You need a way to translate GIS coordinates into map coordinates. The rest follows naturally. If GIS coordinates are carthesian, you merely need the GIS coordinates of two diagonally opposite map corners. You can then scale and translate as needed to convert any GIS coordinate. If GIS coordinates are polar you can essentially do the same, but you'll have to convert between polar and carthesian coordinates as well. -- Oscar Kind http://home.hccnet.nl/okind/ Software Developer for contact information, see website PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2 ========================================================================== TOPIC: getting the disk absolute path of a web-app http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cbdd00f8c8b7f37a ========================================================================== == 1 of 1 == Date: Sat, Nov 6 2004 12:22 pm From: Juha Laiho <[EMAIL PROTECTED]> [EMAIL PROTECTED] (yair) said: >in a servlet running in tomcat, how can i get the full path of my web >application on the disk (something like "c:\progran >files\tomcat\webapps\myApp")? >i don't want to write it in the web.xml or to pass it as a system >property. Adding to the response by Will Hartung; for what would you need this; what would you do with the information? Once we know that, we may be able to propose alternative ways of solving the problem. -- Wolf a.k.a. Juha Laiho Espoo, Finland (GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++ "...cancel my subscription to the resurrection!" (Jim Morrison) ========================================================================== TOPIC: newbie - jdbc Problem http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3b61df05d633ffba ========================================================================== == 1 of 2 == Date: Sat, Nov 6 2004 2:21 pm From: steve <[EMAIL PROTECTED]> On Sat, 6 Nov 2004 21:02:13 +0800, Rhino wrote (in article <[EMAIL PROTECTED]>): > > "Steve Horsley" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Xarky wrote: >>> Hi, >>> I have the following code: >>> >> <snip> >>> >>> result = stmt.executeQuery ("SELECT hours FROM HoursLog WHERE >>> programmer='Pete';"); >>> data = result.getInt("hours"); >>> data = data - 2; >>> >>> con.setAutoCommit(true); >>> stmt.executeUpdate ("UPDATE HoursLog SET hours = data WHERE >>> programmer= 'Pete'"); >>> >>> con.setAutoCommit(false); >>> } // end try statment >>> catch(SQLException e) >>> { >>> System.out.println ("Problems executing statment\n"+e.toString()); >>> System.exit(-1); >>> } // end catch statment> result = stmt.executeQuery ("SELECT hours FROM > HoursLog WHERE >>> programmer='Pete';"); >>> data = result.getInt("hours"); >> >>> } // end method Transactions >>> } // end class >>> >>> >>> DatabaseManager myDB = new DatabaseManager(); >>> myDB.connection(); >>> myDB.Transactions(); >>> >>> My problem is in method Transactions. It is giving me an error on >>> line >>> data = result.getInt("hours"); >>> >>> What I am trying to do is getting the number of hours of Pete, and >>> reducing it by 2. >>> >>> Error given is- "java.sql.SQLException: [Microsoft][ODBC Driver >>> Manager] Invalid cursor state" >>> >>> Can someone help me solve my problem >>> >> Try this: >> result = stmt.executeQuery ("SELECT hours FROM HoursLog WHERE > programmer='Pete';"); >> boolean foundSomething = result.next(); >> if(!foundSomething) { >> // do somethig about this error >> } >> data = result.getInt("hours"); >> >> The result set is originally pointing at a place BEFORE the first line of > the results. >> > While this analysis of the original poster's problem is essentially correct, > this solution is not very good: the technique is poor and some other > problems with the original poster's code are not addressed. Here is a better > example that the original poster can imitate: > > *************** > String queryTableSQL = > > "select lastname, workdept, salary, hiredate " + > > "from " + demoTable + " " + > > "where workdept = 'D21' "; > > /* Query the demonstration table to get information about certain employees. > */ > > Statement queryTableStmt = null; > > ResultSet rs01 = null; > > try { > > queryTableStmt = conn01.createStatement(); > > rs01 = queryTableStmt.executeQuery(queryTableSQL); > > } > > catch (SQLException excp) { > > System.err.println(CLASS_NAME + "." + METHOD_NAME + " - Encountered > SQLException while trying to get information from " + demoTable + " > table. Error: " + excp); > > excp.printStackTrace(); > > System.exit(16); > > } > > > String spaces = " "; > > /* Initialize the host variables used for handling the result set. */ > > String lastname = null; > > String workdept = null; > > BigDecimal salary = null; > > java.sql.Date hiredate; > > > /* Print each line of the result set. */ > > try { > > while (rs01.next()) { > > lastname = rs01.getString(1); > > workdept = rs01.getString(2); > > salary = rs01.getBigDecimal(3); > > hiredate = rs01.getDate(4); > > System.out.println(lastname + spaces + workdept + spaces + > salary.toString() + spaces + hiredate); > > } > > } > > catch (SQLException sql_excp) { > > System.err.println(CLASS_NAME + "." + METHOD_NAME + " - Encountered > SQLException while reading " + demoTable + " table. Error: " + sql_excp); > > sql_excp.printStackTrace(); > > System.exit(16); > > } > > /* Close the result set, dispose of the statement, and commit. */ > > try { > > rs01.close(); > > queryTableStmt.close(); > > conn01.commit(); > > } > > catch (SQLException sql_excp) { > > System.err.println(CLASS_NAME + "." + METHOD_NAME + " - Encountered > SQLException while closing " + demoTable + " result set, closing statement, > or committing. Error: " + sql_excp); > > sql_excp.printStackTrace(); > > System.exit(16); > > } > > } > > *************** > > This example will correctly handle the process of looping through a result > set, even if the result set is empty. (If the result set is empty, the while > loop will simply be skipped in its entirety.) Of course you will probably > want to do something more than simply writing the data to the console but > that's up to you. > > I would strongly suggest finding a JDBC tutorial or book before proceeding > much further. Google should turn up several online tutorials; see if you can > find one that explains things to you in the way that is clearest to you. > > Rhino > > > Rhino ur code is incorrect , it WILL NOT correctly process a database connection. 1. it looks like try & catch city 2. DO NOT DO. try{ setup section 1} catch{} try{ try to do something with section1, also do some section 2 stuff} catch{} try { > > rs01.close(); > > queryTableStmt.close(); > > conn01.commit(); > > } Do the following for closing connections. it is much safer, and will catch any problems. try{ process select , display any results } Catch{ display any errors, set any reporting flags} finally { if (rset != null) { try { rset.close(); } catch (Exception ex) { //print error here // Error_stuff.handleError(ex, -1, -1); } } if (queryTableStmt != null) { try { queryTableStmt .close(); } catch (Exception ex) { //print error here // Error_stuff.handleError(ex, -1, -1); } if (conn01 != null) { try { conn01.close(); } catch (Exception ex) { //print error here // Error_stuff.handleError(ex, -1, -1); } } Do not have multiple try catches, for each operation ,have 1 only and beef up on you error logic. because , logically if your first set of code fails, for the select, records, then everything else will too. You are just making multiple Exceptions for no reason, where 1 will do. and WTF is : conn01.commit();? you have not written any transactions, DO NOT commit!!, this is a very had bug to find for an example of full routine, and how it goes together, see below. This will return a correctly sizing , table , without it being code dependent, for col type or size. by changing the call & execute statements ,it will work for a select. public Vector getCountrytable() { Vector returnedvector = new Vector(); try { String The_qry = ""; ResultSet rset = null; OracleCallableStatement cstmt = null; The_qry = "{?=call external_user.PACKAGE_02.RETURN_countries(" + "'" + "')}"; cstmt = (OracleCallableStatement) dbconn.prepareCall(The_qry); cstmt.registerOutParameter(1, OracleTypes.CURSOR); cstmt.execute(); //this will change it to a simple sql select ( just remove the above 4 lines) // String sql ="select * from a_table" // PreparedStatement st = connection.prepareStatement(sql); // rset = st.executeQuery(); // Execute Query rset = ((OracleCallableStatement) cstmt).getCursor(1); java.sql.ResultSetMetaData rsmd = rset.getMetaData(); int ColumnCount = rsmd.getColumnCount(); // Loop through ResultSet rows int loop = 0; while (rset.next()) { //we could use an object type here, and get the actual data //without doing a toString. ( see get supplier record) //but that requires keeping track of the column types String[] record1 = new String[ColumnCount]; for (int i = 0; i < record1.length; i++) { record1[i] = (String) rset.getString(i + 1); // COPY THE DATA TO A LOCAL ARRAY OF THE RIGHT SIZE } loop++; returnedvector.addElement(record1); } } catch (Exception e) { Error_stuff.handleError(e, EXEPTION_ERROR, -1); } finally{ if (rset != null) { try { rset.close(); } catch (Exception ex) { Error_stuff.handleError(ex, -1, -1); } } if (cstmt!= null) { try { cstmt.close(); } catch (Exception ex) { // Error_stuff.handleError(ex, -1, -1); } } } return returnedvector; } == 2 of 2 == Date: Sun, Nov 7 2004 12:36 am From: steve <[EMAIL PROTECTED]> On Sun, 7 Nov 2004 15:35:00 +0800, Xarky wrote (in article <[EMAIL PROTECTED]>): > Following all your help, I did as follows: > > public void Transactions() > { > ResultSet result = null; > String query01 = null; > String query02 = null; > boolean flag; > int data=0; > > query01 = "SELECT hours FROM HoursLog WHERE programmer='Pete'"; > query02 = "UPDATE HoursLog SET hours ="+ data+ "WHERE programmer= > 'Pete'"; > System.out.println ("Trying to make a transaction on HoursLog > table."); > try > { > System.out.println ("Step 1"); > con.setAutoCommit(true); > result = stmt.executeQuery (query01); > System.out.println ("Step 2"); > flag = result.next(); > if (flag) > { > data = result.getInt("hours"); > data = data + 2; > System.out.println ("Step 3"); > stmt.executeUpdate (query02); > System.out.println ("Step 4"); > } // end if > else > { > System.out.println ("Data searched not found."); > } // end else > con.setAutoCommit(false); > System.out.println ("Transaction on HoursLog table completed."); > } // end try statment > catch(SQLException e) > { > System.err.println ("DatabaseMangager.Transactions() - > Encountered > SQLException while trying to make a transaction on HoursLog table."); > System.err.println (e); > e.printStackTrace(); > System.exit(16); > } // end catch statment > } // end method Transactions > > Now I, my problem is between Step 3 and Step 4. Here I am executing > an Update Query. My problem should be that I am not assigning the > variable data to the query correctly. > > Can you please give me further help. > > > Thanks in Advance > > >> Try this: >> result = stmt.executeQuery ("SELECT hours FROM HoursLog WHERE >> programmer='Pete';"); >> boolean foundSomething = result.next(); >> if(!foundSomething) { >> // do somethig about this error >> } >> data = result.getInt("hours"); >> >> The result set is originally pointing at a place BEFORE the first line of >> the results. >> >> Steve this will not compile, so how do you know it does not work? int data =0; query02 = "UPDATE HoursLog SET hours ="+ data+ "WHERE programmer= 'Pete'"; String data="0"; query02 = "UPDATE HoursLog SET hours ="+ data+ "WHERE programmer= 'Pete'"; might work, but you cannot directly add an int to a string. also this will produce a query like: UPDATE HoursLog SET hours =0WHERE programmer='Pete'" notice there is a MISSING SPACE between "0" and WHERE, your query string is wrong!!! ========================================================================== TOPIC: Performance of null tests? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e1febd5672a2f269 ========================================================================== == 1 of 1 == Date: Sat, Nov 6 2004 2:30 pm From: steve <[EMAIL PROTECTED]> On Sat, 6 Nov 2004 01:14:02 +0800, Adam wrote (in article <[EMAIL PROTECTED]>): > Wow - that's a lot of responses, cheers everyone! > > That is what I suspected and our next step will be to evaluate a load > of different points in the code with this in mind. Based on the > likelihood of a null scenario! > > Just to give a bit of context, this is part of a server side method > called heavily by a multitude of clients - ergo performance is > paramount, easily readable code can be sacrificied (but mitigated with > verbose comments, one hopes). > > And no, I'm not a student ;) For good code design you should not be using exceptions , to do "if", "while","case" processing. There is a very good article on the sun java site , called ( i think) "use & abuse of exceptions" Your "use" sun classes as serious "abuse", but they also go indepth as to why you should not do it (giving timings etc. basically when you cause an exception you are creating an object each time it occurs), and it is very expensive in time. Finally if it is server side code ( and considering your user load) , consider , the operation of generating thousands of exceptions, both on memory & time. Eeeewwwww!!. :-) steve ========================================================================== 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: Sat, Nov 6 2004 2:53 pm From: NOBODY <[EMAIL PROTECTED]> > Times for Object.wait() are quite uninteresting IMHO because you can't > change them anyway. Also, Object.wait() does not much - most of the > time spent in this methods a thread is stopped because it waits for > Object.notify() (or notifyAll()). The overhead of recording this > thread's status etc. is neglectible IMHO. IMHO, you are not on the track... ;-) Lemme exlain again. I know 'wait()' is uninterresting. And I expect it to disappear from results too! But it doesn't, in a very annoying way... The fact is, (if you had read the link I sent), you would have understood that optimizeit may report false non-null cpu time for a thread that went out, did some work (JVMPI thread events that flag it as non blocked) and went back in the wait() (or sleep, or i/o read, etc...), between profiler 2 samples (lets say 5 ms). OI will report that this method (known as blocking only to humans, not the profiler) actually did some work as per the JVMPI events. Even if the work was only 0.1 ms of a 5 ms time window, OI will report that the method, here the wait(), has worked 5 ms. Basically, if I got Will McQueen right, OI will only be told when a thread is blocking/unblocking, it does timestamp those JVMPI events to sum up cpu time, but doesn't save it per method/line at a lower granularity than the stackframe seen by the corser sampler (5ms). It only raise an activity flag ans assigns the time to that method/line. > How did you determine that it's that far off? I profile with sampling mode, per line, not method, the line is an Object.wait() and the profiler reports ~70% of time in that method. Can't be clearer. Beside, many other users have complained about that problem. This post is about figuring solution to a know problem. I don't have to argue about its existence. > I find OptimizeIt very useful. Maybe you just use it the wrong way. > What exactly is it that you want to determine? I have used OI for the last 6 years. I think I know how to use it. What I want to determine is the real wait() %cpu due to real contention to reaquire the monitor. Right now, I've put many hour tuning and fixing hypothetical performance problems and yet, the know design pattern to improve the performance don't solve the problem, which means they were not the problem at first. I was mislead by bad profiler results. I want to know how to eliminate/minimize those wrong results. Thanks. ========================================================================== TOPIC: How do you cast to array? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/884dee2def4bbb47 ========================================================================== == 1 of 1 == Date: Sat, Nov 6 2004 3:27 pm From: NOBODY <[EMAIL PROTECTED]> >> (I cannot believe the % of coders forgetting that 'new' is >> expensive...) > > And I cannot believe the number of people still believing this. It's a > thing of the past. Nowadays, object creation is highly optimized and > very fast in most cases. I won't argue on low throughput system. But on high throughput system (thousands/millions of processes per seconds), sorry to be pedantic but you can't afford, for example: -to trash memory with Long or Integer wrappers as keys to maps instead of using intkeyhashmaps or longkeyhashmaps -to create new stringbuffers everytime to return a string instead of threadlocal-caching them. -to keep using iterators even on an arraylist (iterator trashing) -to not get that not using 'new' (and the GC that goes with it) is largely faster (can't say infinity 'cause of object pool access time) than any performance of any 'new' ever coded. -to not get that realtime systems programming is not a matter of 'user perception in seconds' and that every nanoseconds counts for good throughput. For a given code, when ALL known profilers point to some constant hotspot (let's the constructor <init> of some object) and when you remove it by using a pool and your throughput goes one or more magnitude faster, you realize that 'new' IS expensive. As long as you think in seconds, milliseconds, microseconds, whateverseconds, in absolute time, and ignore the 'relative' performance comparison, you can't realize that 'new' IS expensive. ========================================================================== TOPIC: ant newbie question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/37ab639829111df3 ========================================================================== == 1 of 4 == Date: Sat, Nov 6 2004 3:56 pm From: "Ann" <[EMAIL PROTECTED]> New to ant, I am. This seems like it should be simple, but I have not been able to find it in the ant documentation. If it is there, a pointer will suffice. I built a jar file that includes two gif files. The gif files are actually in the jar file. The names of the gif files are in META-INF/INDEX.LIST One of the classes uses the gif files like this: ImageIcon leafIcon = new ImageIcon("TABLE_ICON.gif"); I run the jar file: "java -jar NewDraw.jar" It runs fine, but the gif files don't show up, it appears it is not finding them and using the default. If I extract the gif files into the same directory as the jar file, they are found and used. What change is needed to avoid the extraction? Here is my bulid.xml file ------------------------------- <project name="NewDraw" default="compile" basedir="."> <target name="compile"> <javac srcdir="src" destdir="bin" debug="on" /> </target> <target name="jar" depends="compile"> <jar destfile="NewDraw.jar" basedir="bin" includes="**/*.class" index="true" > <fileset dir="src" includes="**/*ICON*.gif" /> <fileset dir="src" includes="fileNotFound.jpg" /> <fileset dir="src" includes="viewlist.txt" /> <manifest> <attribute name="Built-By" value="${user.name}"/> <attribute name="Main-Class" value="NewDraw"/> </manifest> </jar> </target> <target name="run" depends="jar"> <java classname="NewDraw" classpath="NewDraw.jar" fork="true" /> </target> </project> == 2 of 4 == Date: Sat, Nov 6 2004 6:51 pm From: Real Gagnon <[EMAIL PROTECTED]> > One of the classes uses the gif files like this: > ImageIcon leafIcon = new ImageIcon("TABLE_ICON.gif"); try with something like URL url = this.getClass().getResource("myIcon.gif"); ImageIcon leafIcon = new ImageIcon(url); Bye. -- Real Gagnon from Quebec, Canada * Looking for Java or PB snippets ? Visit Real's How-to * http://www.rgagnon.com/howto.html == 3 of 4 == Date: Sat, Nov 6 2004 8:02 pm From: "Tony Morris" <[EMAIL PROTECTED]> Nothing to do with Ant and everything to do with class loaders. Look up the method getResource of java.lang.Class. -- Tony Morris http://xdweb.net/~dibblego/ == 4 of 4 == Date: Sat, Nov 6 2004 8:22 pm From: "Ann" <[EMAIL PROTECTED]> works great! thanks guys "Real Gagnon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > > > One of the classes uses the gif files like this: > > ImageIcon leafIcon = new ImageIcon("TABLE_ICON.gif"); > > try with something like > > URL url = this.getClass().getResource("myIcon.gif"); > ImageIcon leafIcon = new ImageIcon(url); > > Bye. > > -- > Real Gagnon from Quebec, Canada > * Looking for Java or PB snippets ? Visit Real's How-to > * http://www.rgagnon.com/howto.html ========================================================================== TOPIC: Yahoo! Lies: You can play Capture in Linux http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/273970295076400c ========================================================================== == 1 of 2 == Date: Sat, Nov 6 2004 8:00 pm From: John Bailo <[EMAIL PROTECTED]> Yahoo Games are based in Java. They have added those newer simple games like Collapse, as Java applets. But I noticed a warning at the bottom...you can read it on this image: http://home.earthlink.net/~jabailo/yahoo_capture.jpg It says: Note: Collapse is not compatible with Unix or Macintosh computers. Yet, here I am, playing Collapse just fine in Konqueror. Why does Yahoo LIE ?!?! -- http://www.texeme.com == 2 of 2 == Date: Sat, Nov 6 2004 8:39 pm From: Andrew Thompson <[EMAIL PROTECTED]> On Sun, 07 Nov 2004 04:00:13 GMT, John Bailo wrote: Your choice of cross-post and Follow-Up is quite dubious.. X-post: comp.os.linux.advocacy,comp.lang.java.programmer F'Up: comp.os.linux.advocacy If this is an 'advocacy' question, best to.. X-post: comp.os.linux.advocacy,comp.lang.java.advocacy ..With F'Ups to .. F'Up: comp.lang.java.advocacy *I* have set the follow-ups to c.l.java.advocacy. > Yahoo Games are based in Java. > > They have added those newer simple games like Collapse, as Java applets. > > But I noticed a warning at the bottom...you can read it on this image: > > http://home.earthlink.net/~jabailo/yahoo_capture.jpg Which references this page.. <http://games.yahoo.com/games/downloads/cl.html> That page has an applet element with some interesting aspects to it.. <APPLET code=gamehouse.SuperApplet.class codebase="http://mtab.games.yahoo.com/wbgameshsc/gamehouse" archive="Collapse.zip" height=400 width=460 VIEWASTEXT MAYSCRIPT> I have never heard of VIEWASTEXT.. <PARAM NAME="CABBASE" VALUE="Collapse.cab"> '.cab' files are Win specific. <param name="USERCLASS" VALUE="com.gh.YahooUser"> This possibly allows a connection between the applet and a Yahoo user's account. .. > Note: Collapse is not compatible with Unix or Macintosh computers. > > Yet, here I am, playing Collapse just fine in Konqueror. I suspect there are aspects of the game you have yet to encounter that will fail. My best guess is a Yahoo functionality to report hi-scores back. > Why does Yahoo LIE ?!?! Why do the uninformed jump to ludicrous conclusions?(!?!) -- 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: Reading Stacktrace in J2ME? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c1df4fa6425d1c5 ========================================================================== == 1 of 2 == Date: Sat, Nov 6 2004 8:27 pm From: "Larry Barowski" <MElarrybar-AT-eng_DOT_auburnANOTHERDOTeduEND> "Rhino" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Can anyone tell me how to decipher a J2ME stacktrace? > > I am working on my first couple of J2ME applications. I'm using the Sun > Wireless Toolkit 2.2. When I crash my MIDlet, I get something like this: > > startApp threw an Exception > java.lang.NullPointerException > java.lang.NullPointerException > at javax.microedition.lcdui.ChoiceGroup.<init>(+92) > ... > > Can someone tell me what the signed numbers in brackets mean and how I can > relate them to line numbers in my source code? These are byte code offsets for each method. There are probably IDEs that will let you click on the stack dump lines and jump to the referenced file and the line corresponding to the byte code offset. We are currently adding J2ME capability to jGRASP and it will have this feature. You could look up the line numbers manually if there is some tool that displays byte code offset vs. line number for class files. Also, less conveniently, if you have a debugger that shows both line number and byte code offset for the stack, you could step through the methods until you find the byte offsets. == 2 of 2 == Date: Sun, Nov 7 2004 1:51 am From: "Chris Uppal" <[EMAIL PROTECTED]> Rhino wrote: > > The opcode. Don't ask me why the MIDP emulators do that. I think it's > > dumb that they don't give you a line number... > > > I'll go along with that! I suppose the developers sat down and weighed > their options: "Gee, what should we put in the stacktrace? The line > number just like every other version of Java and something which people > can use, or the opcode, which is useless to just about everyone? Okay, > let's go with the opcode....". I doubt if JVM authors would want to include the extra overhead of finding and decoding debugging information (from the class file) just to generate line number info for each exception (even if it were done lazily in the exception's toString() method, it's still extra code which takes up space). /Especially/ when it's presumably unlikely that anyone would leave debugging info in classfiles intended to live on a resource-constrained device. -- chris ========================================================================== TOPIC: A Java "interface" declaration does not allow a constructor to be specified in it ... http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a241d06ab76f90b8 ========================================================================== == 1 of 5 == Date: Sat, Nov 6 2004 11:28 pm From: Casey Hawthorne <[EMAIL PROTECTED]> A Java "interface" declaration does not allow a constructor to be specified in it -- has this been fixed in Java 1.5? -- Regards, Casey == 2 of 5 == Date: Sat, Nov 6 2004 11:40 pm From: Andrew Thompson <[EMAIL PROTECTED]> On Sun, 07 Nov 2004 07:28:32 GMT, Casey Hawthorne wrote: > A Java "interface" declaration does not allow a constructor to be > specified in it -- has this been fixed in Java 1.5? It was never broken, and I very much doubt it will ever be changed. On what faulty reasoning do you feel you require an interface with a constructor? (Note that I may not be qualified to supply the solution, but am confident others can) -- 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 5 == Date: Sat, Nov 6 2004 11:46 pm From: "Tony Morris" <[EMAIL PROTECTED]> "Casey Hawthorne" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > A Java "interface" declaration does not allow a constructor to be > specified in it -- has this been fixed in Java 1.5? > > -- > Regards, > Casey It was never broken. There is good reason for this. Without writing a 2000 page essay, I can perhaps recommend a solution that seems to fit the *real* problem when this flawed train of thought arises since I see it every so often. I'm speculating you want to enforce that implementations are constructed such that they take 1 or more arguments. This is not a correct idea to have - after all, how will you access that member? Constructors and interfaces should be thought of independantly, since a constructor belongs only in an implementation (it's only logical after some thought). What you possibly want is the ability to access some member of an implementation - this is easily achieved by providing an accessor method on the interface. Without more information, only speculation can be provided. The only 'concrete' thing that can be said is that you have not provided a problem, but a broken solution. I have seen this more times over the years than I care to remember (perhaps in the hundreds?) - I decided to call it YARD - Yet Another Requirements Defect. -- Tony Morris http://xdweb.net/~dibblego/ == 4 of 5 == Date: Sun, Nov 7 2004 1:18 am From: Tor Iver Wilhelmsen <[EMAIL PROTECTED]> Casey Hawthorne <[EMAIL PROTECTED]> writes: > A Java "interface" declaration does not allow a constructor to be > specified in it -- has this been fixed in Java 1.5? What is to fix? An interface is defined to represent a method "contract" for a class. Constructors do not count as methods for that purpose. You cannot, and were never meant to, "construct" interfaces, just objects of classes implementing the interface. == 5 of 5 == Date: Sun, Nov 7 2004 1:27 am From: Mark Thornton <[EMAIL PROTECTED]> Casey Hawthorne wrote: > A Java "interface" declaration does not allow a constructor to be > specified in it -- has this been fixed in Java 1.5? > > -- > Regards, > Casey You have always been able to specify an interface for factory classes, which is what you ought to use for this purpose. It might be nice syntactic sugar if one could add methods to 'Class' that could then serve as the factory (similar to SmallTalk), but that wouldn't come very high on my priority list for changes. Mark Thornton ======================================================================= 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
