comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Application in sandbox - 6 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/821eb31df84b5c4a * Really (!) correct Semaphore - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b621f16b0eeef712 * Ant vs Makefiles - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e81556a5c62ba767 * Java and C# Dll ... - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9865ceaba8831282 * why can't I pass a squiggly brace expression into a method call? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/320cabcfd15f1d3d * Saving data - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d816da79e80f1fcd * Semaphore events and working part-part-part time. - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/519011440b614d43 * [J2ME]How to avoid memory fragmentation - 3 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cb6a26addf63af68 * Zooming/streching turtle - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e5137c08201f6efb * parseDouble return scientific computing number - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bec9234d8ca5362e * Design question : Parallel Inheritance Hierarchies - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/313558c87276bd65 * [ANN] Unified I/O for Java 2.1 released - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/37c4c6fdb5dd8971 * cancel <[EMAIL PROTECTED]> - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2a76f897816b1890 ============================================================================== TOPIC: Application in sandbox http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/821eb31df84b5c4a ============================================================================== == 1 of 6 == Date: Sun, Nov 28 2004 8:10 am From: Tim Tyler Andrew Thompson <[EMAIL PROTECTED]> wrote or quoted: > On Sat, 27 Nov 2004 21:04:09 GMT, Tim Tyler wrote: > > I have an application (in a Jar file) which I don't trust - and would > > like to run securely - in a sandbox. > > > > Does anyone know the easiest way? > > Launch it from an applet. It will inheret the applet sandbox. So: has anyone done this before? Does it work? One problem I forsee is that any command-line apps requiring input would all fail. A more cosmetic problem would be that it (messily) leaves an appletviewer window hanging around with no content in it. I guess I could live with that. Maybe there's an applet which accepts the main method as a parameter - and then uses reflection to call it? Otherwise you have to recompile Java code each time you want to do this - not exactly a low-hassle approach. Even as it is, it seems you would have to edit HTML files to include the relevant jar files. A WebStart approach may work slightly better than an applet-based one - since the WebStart sandbox is slightly less screwed that the applet sandbox, and it's *designed* for running applications in. There may be more config files to edit there, though. I guess what I /really/ want is something like: "java -sandbox <permission.file>" -- __________ |im |yler http://timtyler.org/ [EMAIL PROTECTED] Remove lock to reply. == 2 of 6 == Date: Sun, Nov 28 2004 8:32 am From: Andrew Thompson On Sun, 28 Nov 2004 08:10:02 GMT, Tim Tyler wrote: > So: has anyone done this before? Probably numerous times. <http://www.physci.org/codes/tame/applet.jsp> You're looking at an applet that launches the JFrames of the Tame Swing codes. Another example of the same applet.. <http://www.physci.org/launcher.jsp#CardTest> All the links lead to source and 'web-launchable' applications. > Does it work? Yes. But then, it only takes about 30 lines of code to test it for yourself. Go on, ..be daring. ;-) -- 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 6 == Date: Sun, Nov 28 2004 8:35 am From: Andrew Thompson On Sun, 28 Nov 2004 08:10:02 GMT, Tim Tyler wrote: ... > I guess what I /really/ want is something like: > > "java -sandbox <permission.file>" ... In that case look to the other solution. It allows more finely grained control. -- 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 == 4 of 6 == Date: Sun, Nov 28 2004 1:59 pm From: Tim Tyler Andrew Thompson <[EMAIL PROTECTED]> wrote or quoted: > On Sun, 28 Nov 2004 08:10:02 GMT, Tim Tyler wrote: > > I guess what I /really/ want is something like: > > > > "java -sandbox <permission.file>" ... > > In that case look to the other solution. It allows more > finely grained control. Yes - the "other solution" has the guts of a usable approach - thanks. -- __________ |im |yler http://timtyler.org/ [EMAIL PROTECTED] Remove lock to reply. == 5 of 6 == Date: Sun, Nov 28 2004 2:31 pm From: Andrew Thompson On Sun, 28 Nov 2004 13:59:37 GMT, Tim Tyler wrote: > Andrew Thompson <[EMAIL PROTECTED]> wrote or quoted: >> On Sun, 28 Nov 2004 08:10:02 GMT, Tim Tyler wrote: > >>> I guess what I /really/ want is something like: >>> >>> "java -sandbox <permission.file>" ... >> >> In that case look to the other solution. It allows more >> finely grained control. > > Yes - the "other solution" has the guts of a usable approach - thanks. You're welcome. -- 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 == 6 of 6 == Date: Sun, Nov 28 2004 6:48 am From: yunhong min test ============================================================================== TOPIC: Really (!) correct Semaphore http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b621f16b0eeef712 ============================================================================== == 1 of 1 == Date: Sun, Nov 28 2004 7:25 pm From: thirdrock Chris Smith wrote: > thirdrock <[EMAIL PROTECTED]> wrote: > >>> while(count==0){ >>> wait(); >> >>Are you going to wait forever here? It's usually good practice to not >>have any place in your code that can be caught in an infinite loop. > > > Nonsense. You can't preempt every possible poor usage of an API, and > simplicity is its own goal. If you need a semaphore that can time out, > then Frank's implementation isn't for you; but 99% of semaphores don't > need to time out, > Hmmm, I seem to recall from another API (not java) a function called WaitForObject(HANDLE object, int milliseconds). If milliseconds == 0 then it waits forever, otherwise, it waits for as long as you are prepared to wait before doing something else. If this code was being executed from a servlet, and the http timeout was 60 seconds, would you want the semaphore waiting longer than 60 seconds? > and I'd be really peeved if Frank guessed about how > long a P() might need to wait and was wrong, Yes, I would be peeved if I couldn't pass a parameter with the maximum time I was prepared to wait for the semaphore. >and it crashed my > production application as a result. I have no idea how a SemaphoreTimedOut exception could crash your production application. I have to assume that you don't catch exceptions in your production applications. Ian ============================================================================== TOPIC: Ant vs Makefiles http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e81556a5c62ba767 ============================================================================== == 1 of 1 == Date: Sun, Nov 28 2004 10:02 am From: Juha Laiho "Ann" <[EMAIL PROTECTED]> said: >Great, then maybe you can suggest a solution for me since I am >new to Ant. I have a file that contains mostly constants. When >it changes there are a dozen other files that must be recompiled. Hmm.. that sounds like a combination of a property file and a class to me. So, if you have constant values, separate them into a property file that is read when the class is loaded (or an instance created, whichever suits better to the logic). Then have a separate class (without the external data), that just contains the dynamic behaviour you need - and have the dependent classes call that class to get the information they need. This should relieve you from recompiling just because a piece of "constant data" did change - instead just modify the data and repackage/redeploy the application. -- 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: Java and C# Dll ... http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9865ceaba8831282 ============================================================================== == 1 of 2 == Date: Sun, Nov 28 2004 12:16 pm From: "Piccolo Max" Hello everybody, I have developer a .dll (.net assembly) that contain 2 Class. I want to know If I can load this dll from Java and use the 2 Class. Can i do it ? max; == 2 of 2 == Date: Sun, Nov 28 2004 12:19 pm From: Davide Consonni Piccolo Max wrote: > Hello everybody, > I have developer a .dll (.net assembly) that contain 2 Class. > > I want to know If I can load this dll from Java and use the 2 Class. > Can i do it ? you can't. -- Davide Consonni http://csvtosql.sourceforge.net ============================================================================== TOPIC: why can't I pass a squiggly brace expression into a method call? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/320cabcfd15f1d3d ============================================================================== == 1 of 1 == Date: Sun, Nov 28 2004 1:07 pm From: Michael Borgwardt Kevin Simonson wrote: > I have written a piece of code where it would be really handy if I > could pass an array defined as a series of values, separated by com- > mas, and enclosed by squiggly braces, into a method call. BTW, the technical expression for that is "array literal". ============================================================================== TOPIC: Saving data http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d816da79e80f1fcd ============================================================================== == 1 of 1 == Date: Sun, Nov 28 2004 1:14 pm From: Michael Borgwardt Chris Smith wrote: > 6. Use a relational database. Any time you feel the need to have > multiple different users or processes interacting with data at the same > time, or perform checking to ensure that the data does not become > inconsistent with itself over time, or share data over a large number of > users, or update data in real time, you should strongly consider using a > relational database Hm. I'd say that the first and most likely indicator for needing a DB is when you want to do a lot of queries on different fields. In Java, this would manifest as having lots of Maps and Sets with non-empty intersections. Oh, and API reference: java.lang.sql, hand Java implementation: http://hsqldb.sourceforge.net/ ============================================================================== TOPIC: Semaphore events and working part-part-part time. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/519011440b614d43 ============================================================================== == 1 of 1 == Date: Sun, Nov 28 2004 12:34 pm From: Jeff_Relf Hi John, Re: http://www.seattlehousing.org You wrote: << Did you look at it ? Seattle Housing has a program where you can get a 1-bedroom apartment in neighborhoods like Greenlake and they will pay 70% percent of the rent ! They say that you would pay about 30%, but no more than 40% of your monthly income for rent. Since you make $3600 a year, and your monthly is $300, then you would be paying about $100 a month under this program and get a full apartment, not just a room ....which, I believe you pay $270 for. >> I'm paying 250 for rent/utilities. I earned 5,600 in 2004, which averages to 467 per month, so that'd be 140 per month ( 467 * .3 ). Yea, I should probably do that... so Rick could have a reason to exist. ( Yes, I prefer part-part-part time work ) Another problem is that I'm self-employed with inconsistent income, which DSHS doesn't seem to understand... and it raises some fraud flags. I don't know, that sounds like a lot of work and I like my little hovel. I could probably finagle free dental-crowns too ( like Jeff Borowiak ), but again... I'm just too lazy to do that. Re: That Linus/K-Man benchmark, You need to suspend your thread pending a semaphore event, Go = CreateEvent( 0, 1, 0, 0 ) creates a semaphore event, initialized to off. WaitForSingleObject( Go, LoveYouLongTime ) suspends your thread and SetEvent( Go ) resumes it. ...A " synchronized statement " doesn't cut it. You wrote: << I'll stick with 2000 [ theads ], and you should too, even make it 1000, so it can be compared to the c# code as well. >> No, measuring how many threads can be created is the most fundamental part of this benchmark. It'd be nice if you scaled up the duration to 100,000 threads, e.g. if you get 2,008 threads in 1.15 seconds, report this: const int Req = 3000 ; HANDLE TH [ Req ]; HANDLE Go ; ....... double Mark = Secs ; HANDLE * pH = TH - 1 ; int Threads ; Go = CreateEvent( 0, 1, 0, 0 ); // Do as many spawns/completions as you can. { Loop ( Req ) if ( ! ( * ++ pH = CreateThread( 0, 1, Test, 0, 0, 0 ) ) ) break ; Threads = J ; } pH = TH - 1 ; SetEvent( Go ); Loop ( Threads ) WaitForSingleObject( * ++ pH, LoveYouLongTime ); // 2,008 Simultaneous threads acheived. // 57 Seconds per 100,000 simultaneous threads spawned/completed. double Dur = Secs - Mark ; Sh("%d Simultaneous threads acheived.", Threads ); Sh("%d Seconds per 100,000 simultaneous threads spawned/completed." , int( Dur / Threads * 100 * 1000 ) ); Re: Your Java code: << long now = System.currentTimeMillis(); SimpleThread[] st = new SimpleThread[ nthreads ]; int i ; for ( i = 0; i < nthreads; i++ ) { st[i] = new SimpleThread("#" + i); >> Where exactly are the threads getting spawned here ? Doesn't new SimpleThread[ nthreads ] do the spawning ? ( If so, that's a serious problem ) You wrote: << I'll enclose it in a try/catch block to handle exceptions. It's the standard OOP way. >> Fine, as long as you know where the threads are being spawned ...and you have a way to count them... try-catch may not cut it. ============================================================================== TOPIC: [J2ME]How to avoid memory fragmentation http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cb6a26addf63af68 ============================================================================== == 1 of 3 == Date: Sun, Nov 28 2004 8:28 am From: "Darryl L. Pierce" DNass wrote: > I have developped a mobile app, > and I'm actually trying to deploy this app > on a Sony Ericsson T610. > On the emulator it works just fine, but on the mobile > I have this system error message saying "this application is > using too much memory", I know that the app uses about 150k of RAM > and the mobile has 260 k > there for I thougth it was due to > a problem with the memory fragmentation. > I was wondering if somebody here had the same problems > and if yes could she/he share his experience > > Thx in advance > > PS: the app make connections to server via http > to retreive informations (text and/or images) The mobile may have 260k, but remember that some of that is going to be taken up by the ROM image of your application. So, if you're using 150k of heap, you're only leaving 110k for the ROM image and stack space, which isn't very much at all. Emulators based on the WTK always have 512k for their heap so you're hard pressed to use up their memory. I would say first off go through your code and reduce that heap usage. What are you using 150k for? Seems that you should put some of that data into RMS or else let it go 'cause that's way too much for almost any handset to handle. -- Darryl L. Pierce <[EMAIL PROTECTED]> Visit my webpage: <http://mcpierce.multiply.com> "By doubting we come to inquiry, through inquiry truth." - Peter Abelard == 2 of 3 == Date: Sun, Nov 28 2004 8:29 am From: "Darryl L. Pierce" JScoobyCed wrote: >> I have this system error message saying "this application is >> using too much memory", I know that the app uses about 150k of RAM >> and the mobile has 260 k > > > If the application has pictures, try to decrease their sizes. This will > help lowering the app size. Then use an obfuscator to optimize the byte > code and reduce again the size. Very good point! The one I would recommend is Proguard. It's free and does a bang up job of shrinking the size of MIDlet suites. -- Darryl L. Pierce <[EMAIL PROTECTED]> Visit my webpage: <http://mcpierce.multiply.com> "By doubting we come to inquiry, through inquiry truth." - Peter Abelard == 3 of 3 == Date: Sun, Nov 28 2004 8:30 am From: "Darryl L. Pierce" DNass wrote: > when I see the content length of the file received and the amount > of free memory (with the method Runtime.getRuntime().freeMemory()) it seems > that > my app can handle the response but then I have the error message. But the data received has to be wrapped in HTTP buffers (which take up memory) and then transferred to a byte array (which takes up some more memory). In the process, you may even end up having the data doubled in memory if it's copied from the HTTP buffer to the byte array, rather than being passed completely. All in all, the tip is to only accept data that's smaller than half of available memory. -- Darryl L. Pierce <[EMAIL PROTECTED]> Visit my webpage: <http://mcpierce.multiply.com> "By doubting we come to inquiry, through inquiry truth." - Peter Abelard ============================================================================== TOPIC: Zooming/streching turtle http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e5137c08201f6efb ============================================================================== == 1 of 2 == Date: Sun, Nov 28 2004 2:37 pm From: "Adrian M. Hanslik" Hello there, I'm working on the well-known graphic demo 'turtle', which will be included in a larger project, where I have to simulate a route of a robot. As I'd like to insert functions like zooming, streching etc., I'd like to know which classes are most suitable for that? At the moment I'm using the drawLine-method for the path. But it's hard to insert a zoom function to it, as I have to save all coordinates an calculate the changes, which is very time-consuming, it flickers, ... Are there any better ideas for a solution? Thank you very much Adrian == 2 of 2 == Date: Sun, Nov 28 2004 2:16 pm From: Andrew Thompson On Sun, 28 Nov 2004 14:37:44 +0100, Adrian M. Hanslik wrote: > I'm working on the well-known graphic demo 'turtle', As you mentioned on c.l.j.gui. Please don't multi-post. <http://www.physci.org/codes/javafaq.jsp#xpost> -- 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: parseDouble return scientific computing number http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bec9234d8ca5362e ============================================================================== == 1 of 2 == Date: Sun, Nov 28 2004 5:42 am From: [EMAIL PROTECTED] (Quick Function) if I use Double.parseDouble("0.0005"), it will return 5 E-4. How can I get 0.0005? Thanks, qq == 2 of 2 == Date: Sun, Nov 28 2004 2:14 pm From: Andrew Thompson On 28 Nov 2004 05:42:22 -0800, Quick Function wrote: > if I use Double.parseDouble("0.0005"), it will return 5 E-4. How can I > get 0.0005? <http://java.sun.com/j2se/1.5.0/docs/api/java/text/NumberFormat.html> 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: Design question : Parallel Inheritance Hierarchies http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/313558c87276bd65 ============================================================================== == 1 of 3 == Date: Sun, Nov 28 2004 5:57 am From: [EMAIL PROTECTED] (Tomer Ben-David) Hi In his book "Refactoring improving the design of existing code" martin fowler writes about the bed smell "Parallel Inheritance Hierarchies". Lets take this for example : Person Student extends Person Employee extends Person Now lets say I want to turn those classes into XML, adding the XML to the Person/Employee/Student classes themselvs could be a possibility but in real world (at work) those classes tend to grow (and lets assume for the sake of the example i dont use jaxb etc...), so I would like to have this functionality out of these classes, in something that looks like PersonXMLHelper StudentXMLHelper extends PersonXMLHelper EmployeeXMLHelper extends PersonXMLHelper However Now I have the bed smell "Parallel Inheritance Hierarchies". Can anyone suggest a better simple design? I come across this problem over and over again... Thanks == 2 of 3 == Date: Sun, Nov 28 2004 2:19 pm From: "VisionSet" "Tomer Ben-David" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi > > In his book "Refactoring improving the design of existing code" martin > fowler writes about the bed smell "Parallel Inheritance Hierarchies". > > Lets take this for example... > I come across this problem > over and over again... So do I. Why is it a bed(sic) smell? At the moment I have 3 (M,V,C) parallel hierachies that represent an MVCesque set of tables. -- Mike W == 3 of 3 == Date: Sun, Nov 28 2004 2:28 pm From: Andrew Thompson On 28 Nov 2004 05:57:17 -0800, Tomer Ben-David wrote: > ..bed smell.. Bed smell? Is that a reference to nocturnal flatulence? -- 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: [ANN] Unified I/O for Java 2.1 released http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/37c4c6fdb5dd8971 ============================================================================== == 1 of 1 == Date: Sun, Nov 28 2004 3:02 pm From: "Andrei Kouznetsov" Unified I/O is a high performance Java library that allows random access files, arrays, streams (even over HTTP), and gives a clear difference between read only and read/write access. Features: * High performance (see http://uio.imagero.com/performance.html) * Transparent buffering. * Access everything using one common interface. * Read/write direct from/into primitive arrays * Choose byte order for particular read/write operation * Change byte order at any time. * Define start offset and length. * Optimized reading over http (only requesting the required data range of bytes - uses byteserving feature of http 1.1). * Easy extensible design For more possibilities see RandomAccessFactory. what's new in version 2.1: some bugs related to reading/writing of primitive arrays were fixed. -- Andrei Kouznetsov https://uio.dev.java.net Unified I/O for Java http://reader.imagero.com Java image reader http://jgui.imagero.com Java GUI components and utilities ============================================================================== TOPIC: cancel <[EMAIL PROTECTED]> http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2a76f897816b1890 ============================================================================== == 1 of 1 == Date: Sun, Nov 28 2004 6:44 am From: [EMAIL PROTECTED] This message was cancelled from within Mozilla. ============================================================================== 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
