RE: Java help - convert -D command line option to CF?
Perhaps, you can try to instantiate java.lang.System and set the system property in the coldfusion code? Something like, cfset sys = createObject(java, java.lang.System) cfset sys.setProperty(com.java4less.vision.maxarea, 9) Hope that helps. Thanks, Hareni -Original Message- From: Ryan Stille [mailto:[EMAIL PROTECTED] Sent: 08 December 2007 04:19 To: CF-Talk Subject: Java help - convert -D command line option to CF? I am converting a little java code into CF8. The sample Java program I am working from is meant to be run with this command line option: -Dcom.java4less.vision.maxarea=90 Without having that set, my results in ColdFusion are not working very well. Anyone know how I can do something like the above in ColdFusion? I have no vision object to work with or anything, I'm only working with 1 instantiated java object and there is no maxarea property or setter in that object. I imagine I could change ColdFusion's JVM start up parameters to include that option, but I don't really like that idea. -Ryan ~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:294395 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Java help - convert -D command line option to CF?
Hareni that worked great, thank you! -Ryan Hareni Venkatramanan wrote: Perhaps, you can try to instantiate java.lang.System and set the system property in the coldfusion code? Something like, cfset sys = createObject(java, java.lang.System) cfset sys.setProperty(com.java4less.vision.maxarea, 9) Hope that helps. Thanks, Hareni -Original Message- From: Ryan Stille [mailto:[EMAIL PROTECTED] Sent: 08 December 2007 04:19 To: CF-Talk Subject: Java help - convert -D command line option to CF? I am converting a little java code into CF8. The sample Java program I am working from is meant to be run with this command line option: -Dcom.java4less.vision.maxarea=90 Without having that set, my results in ColdFusion are not working very well. Anyone know how I can do something like the above in ColdFusion? I have no vision object to work with or anything, I'm only working with 1 instantiated java object and there is no maxarea property or setter in that object. I imagine I could change ColdFusion's JVM start up parameters to include that option, but I don't really like that idea. -Ryan ~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:294408 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Java help - convert -D command line option to CF?
I am converting a little java code into CF8. The sample Java program I am working from is meant to be run with this command line option: -Dcom.java4less.vision.maxarea=90 Without having that set, my results in ColdFusion are not working very well. Anyone know how I can do something like the above in ColdFusion? I have no vision object to work with or anything, I'm only working with 1 instantiated java object and there is no maxarea property or setter in that object. I imagine I could change ColdFusion's JVM start up parameters to include that option, but I don't really like that idea. The component in question is probably this: http://www.java4less.com/vision/vision.php Presumably, your class is either using this, or using something which is using this? Anyway, it seems to me that you have three options. Add the option to jvm.config, invoke your program from CFEXECUTE instead of integrating it into your CF code, or modify the source code of the component to contain this value as a default. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| Create robust enterprise, web RIAs. Upgrade to ColdFusion 8 and integrate with Adobe Flex http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:294391 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Java help
Thanks for the suggestion. I saw that link before but dismissed it for some reason. I guess I assumed it was doing something else. In any event, I just tried it and it DID come up with different output but still not what it should be. I may very well be using it wrong though. It's probably obvious that I'm no Java programmer. I'm basically just taking what I know about programming in general and the syntax of JavaScript and doing the best I can here. This is what I have from your suggestion and what it displays. import java.text.*; import java.math.BigDecimal; public class dollarFormattingTest { public static void main(String[] args) { DecimalFormat dollarFormat = new DecimalFormat($0.00); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.815))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.825))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.835))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.845))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.855))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.865))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.875))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.885))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.895))); } } This is the output now... $71.81 $71.83 $71.83 $71.84 $71.86 $71.86 $71.88 $71.89 $71.89 That's either extremely weird... or I'm completely missing something obvious. :-/ -Original Message- From: Denny Valliant [mailto:[EMAIL PROTECTED] Sent: Saturday, October 07, 2006 1:25 AM To: CF-Talk Subject: Re: Java help Could this be it? http://forum.java.sun.com/thread.jspa?threadID=736383messageID=4230346 On 10/6/06, Bobby Hartsfield [EMAIL PROTECTED] wrote: I should also mention that I tried this as well... . -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.407 / Virus Database: 268.13.0/465 - Release Date: 10/6/2006 ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255882 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Java help
Bobby, I think this is what you want: import java.math.*; import java.text.*; import java.util.Locale; public class BigDecimalFormatTest { public static void main (String[] args) { double [] nums = {71.715,71.725,71.735,71.745,71.755,71.765,71.775,71.785, 71.795}; NumberFormat form; form = NumberFormat.getCurrencyInstance(Locale.US); for (int i = 0; i nums.length; ++i) { BigDecimal theNumber = new BigDecimal (Double.toString(nums[i])); theNumber = theNumber.setScale(2, RoundingMode.HALF_UP); System.out.println(form.format(theNumber)); } } } The key here is the double conversion to BigDecimal and setting the rounding mode to half_up. The reason you weren't getting what you thought you should is because DecimalFormat uses the half_even rounding mode. Dina On 10/7/06, Bobby Hartsfield [EMAIL PROTECTED] wrote: Thanks for the suggestion. I saw that link before but dismissed it for some reason. I guess I assumed it was doing something else. In any event, I just tried it and it DID come up with different output but still not what it should be. I may very well be using it wrong though. It's probably obvious that I'm no Java programmer. I'm basically just taking what I know about programming in general and the syntax of JavaScript and doing the best I can here. This is what I have from your suggestion and what it displays. import java.text.*; import java.math.BigDecimal; public class dollarFormattingTest { public static void main(String[] args) { DecimalFormat dollarFormat = new DecimalFormat($0.00); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.815))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.825))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.835))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.845))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.855))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.865))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.875))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.885))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.895))); } } This is the output now... $71.81 $71.83 $71.83 $71.84 $71.86 $71.86 $71.88 $71.89 $71.89 That's either extremely weird... or I'm completely missing something obvious. :-/ -Original Message- From: Denny Valliant [mailto:[EMAIL PROTECTED] Sent: Saturday, October 07, 2006 1:25 AM To: CF-Talk Subject: Re: Java help Could this be it? http://forum.java.sun.com/thread.jspa?threadID=736383messageID=4230346 On 10/6/06, Bobby Hartsfield [EMAIL PROTECTED] wrote: I should also mention that I tried this as well... . -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.407 / Virus Database: 268.13.0/465 - Release Date: 10/6/2006 ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255891 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Java help
That appears to be it Dina. Thanks a ton. -Original Message- From: Dina Hess [mailto:[EMAIL PROTECTED] Sent: Saturday, October 07, 2006 1:37 PM To: CF-Talk Subject: Re: Java help Bobby, I think this is what you want: import java.math.*; import java.text.*; import java.util.Locale; public class BigDecimalFormatTest { public static void main (String[] args) { double [] nums = {71.715,71.725,71.735,71.745,71.755,71.765,71.775,71.785, 71.795}; NumberFormat form; form = NumberFormat.getCurrencyInstance(Locale.US); for (int i = 0; i nums.length; ++i) { BigDecimal theNumber = new BigDecimal (Double.toString(nums[i])); theNumber = theNumber.setScale(2, RoundingMode.HALF_UP); System.out.println(form.format(theNumber)); } } } The key here is the double conversion to BigDecimal and setting the rounding mode to half_up. The reason you weren't getting what you thought you should is because DecimalFormat uses the half_even rounding mode. Dina On 10/7/06, Bobby Hartsfield [EMAIL PROTECTED] wrote: Thanks for the suggestion. I saw that link before but dismissed it for some reason. I guess I assumed it was doing something else. In any event, I just tried it and it DID come up with different output but still not what it should be. I may very well be using it wrong though. It's probably obvious that I'm no Java programmer. I'm basically just taking what I know about programming in general and the syntax of JavaScript and doing the best I can here. This is what I have from your suggestion and what it displays. import java.text.*; import java.math.BigDecimal; public class dollarFormattingTest { public static void main(String[] args) { DecimalFormat dollarFormat = new DecimalFormat($0.00); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.815))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.825))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.835))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.845))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.855))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.865))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.875))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.885))); System.out.println(dollarFormat.format(new java.math.BigDecimal(71.895))); } } This is the output now... $71.81 $71.83 $71.83 $71.84 $71.86 $71.86 $71.88 $71.89 $71.89 That's either extremely weird... or I'm completely missing something obvious. :-/ -Original Message- From: Denny Valliant [mailto:[EMAIL PROTECTED] Sent: Saturday, October 07, 2006 1:25 AM To: CF-Talk Subject: Re: Java help Could this be it? http://forum.java.sun.com/thread.jspa?threadID=736383messageID=4230346 On 10/6/06, Bobby Hartsfield [EMAIL PROTECTED] wrote: I should also mention that I tried this as well... . -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.407 / Virus Database: 268.13.0/465 - Release Date: 10/6/2006 ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255905 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Java help
I should also mention that I tried this as well... public static void main(String[] args) { DecimalFormat dollarFormat = new DecimalFormat($#0.00); System.out.println(dollarFormat.format(71.815)); System.out.println(dollarFormat.format(71.825)); System.out.println(dollarFormat.format(71.835)); System.out.println(dollarFormat.format(71.845)); System.out.println(dollarFormat.format(71.855)); System.out.println(dollarFormat.format(71.865)); System.out.println(dollarFormat.format(71.875)); System.out.println(dollarFormat.format(71.885)); System.out.println(dollarFormat.format(71.895)); } It gives the same exact results. Everything is fine as long as it's not a 5 in the 1000ths position. -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, October 06, 2006 9:19 PM To: CF-Talk Subject: OT: Java help Can anyone lend a hand with this off-list by chance? I need a dollarformat function in Java. I thought I had it but it doesnt round correctly. Take this short example. import java.text.*; import java.util.Locale; public class dollarFormattingTest { public static void main(String[] args) { NumberFormat dollarFormat = NumberFormat.getCurrencyInstance(Locale.US); System.out.println(dollarFormat.format(71.715)); System.out.println(dollarFormat.format(71.725)); System.out.println(dollarFormat.format(71.735)); System.out.println(dollarFormat.format(71.745)); System.out.println(dollarFormat.format(71.755)); System.out.println(dollarFormat.format(71.765)); System.out.println(dollarFormat.format(71.775)); System.out.println(dollarFormat.format(71.785)); System.out.println(dollarFormat.format(71.795)); } } That short program outputs the following $71.72 $71.72 $71.74 $71.74 $71.76 $71.76 $71.78 $71.78 $71.80 If I change all the numbers to put a 6 in the 1000ths position, compile, and run again they all round up fine just as they should. And anything under a 5 in that position seems fine as well (the 1000ths position is simply dropped). Any ideas? -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.407 / Virus Database: 268.13.0/465 - Release Date: 10/6/2006 ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255868 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Java help
Could this be it? http://forum.java.sun.com/thread.jspa?threadID=736383messageID=4230346 On 10/6/06, Bobby Hartsfield [EMAIL PROTECTED] wrote: I should also mention that I tried this as well... ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255872 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4