| Comparing two long numbers |
|
 |
Index ‹ java-programmer
|
- Previous
- 3
- Integrating servlet container into my stand alone AppHello Everyone,
I had this idea for an application I would like to write. I want
to write it as a java application, but be able to output
program-generated .html into an Internet Explorer window. Sending the
generated html to the IE window is easy... just using the Runtime
class. But I want the Internet Explorer window to be able to make http
calls back to my application for form submissions. I didn't want to
have to force my users to install Tomcat just so the internet explorer
could pass back information to the servlet in my .Jar file.
How hard is it to add a servlet container and respond to http post's
from the localhost internet explorer window? This is all from my .jar
file and not from a web application running under tomcat remember. The
only http requests coming into my application will be from that one
internet explorer window... so its really acting like a
single-user-local-machine Tomcat server. But I dont want the burden of
forcing Tomcat on people.
I suppose you'll say pick a standard application or a jsp/servlet
solution, but not both.... but I think there is a lot of flexability
to this method, being able to generate GUI screens on the fly in the
IE window is really exciting.
Thanks,
Greg
- 3
- servlet calling servlet stopped by securityI have two servlets in the same tomcat webapp (A and B) both normally
accessed from the web. Sometimes A needs to access B and I use http to
do that. Actually 'B' is about a dozen other servlets, still all in
the same webapp.
This works just fine until I turn on security constraints. When I do
that and request A the login form works as normal and invokes A
correctly. But when A needs to invoke B I get another logon form
instead of B. This would be okay, I can hack through that, but I only
know the user name, not the password for A's session.
Is there a simpler way to have one servlet in the same webapp invoke
another without having to go through security? I cannot just do java
to java, there are too many entry points (ie cases of 'B') They are
all volatile and need to be exposed to the web.
Thanks for your help
Roger
- 3
- Adding multiple GUI drivers into one windowHello,
I'm reasonably new at java:
I have several classes that create different windows...using JFrame, JPanel
etc, I was wondering how I could add these seperate gui's to one driver
class to have it all show in one window (which i could have a tabbed pane)
If someone understands what i'm blabberin about, please help!
--
Message posted via http://www.javakb.com
- 5
- J2ME: j9 & JSR75?Hi all...
Has anyone tried to install IBM's optional package for JSR75
support on it's PDA?
I am having troubles by lauching the Midlet HQ that would
support FileConnection.
Regards,
Branko
- 5
- Diablo 1.3.1 JVM runs out of file descriptors at 1021I'm using the Diablo 1.3.1 JVM package from www.freebsdfoundation.org on a
4.9-STABLE machine and it unfortunately seems to exhibit the bug described at:
http://developer.java.sun.com/developer/bugParade/bugs/4189011.html
interestingly enough, the linux 1.3.1_02 JVM under a 4.6-STABLE machine does
not exhibit the problem.
Is there an updated Diablo (diablo-jdk-noplugin-1.3.1.0 Java Development Kit
1.3.1 is what I'm running) that has this fixed or is my only recourse, other
than compiling from source, to run under linux emulation?
On the Diablo JVM machine (test.java is the program suggested in the bug
report):
nine[ttyp2]:aditya~> /usr/local/diablo-jdk1.3.1/bin/java test 3000 1 1 test
Starting 1078434190431
Opened test0000001020.tst Thread: 0
test0000001021.tst (Too many open files) java.io.FileNotFoundException:
test0000001021.tst (Too many open files)
Aborting 1078434221065
nine[ttyp2]:aditya~> /usr/local/diablo-jdk1.3.1/bin/java -version
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build diablo-1.3.1-0)
Classic VM (build diablo-1.3.1-0, green threads, nojit)
nine[ttyp2]:aditya~> limit
cputime unlimited
filesize unlimited
datasize 524288 kbytes
stacksize 65536 kbytes
coredumpsize unlimited
memoryuse unlimited
vmemoryuse unlimited
descriptors 11095
memorylocked unlimited
maxproc 5547
sbsize unlimited
And the following on a 4.6-STABLE machine running a 1.3.1_02 JVM under linux
emulation (linux-jdk-1.3.1.02_1 Sun Java Development Kit 1.3 for Linux):
two[ttyp2]:aditya~> java test 3000 1 1 test
Starting 1078434145154
Closing 1078434235337.tst Thread: 0
two[ttyp2]:aditya~> java -version
java version "1.3.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
Classic VM (build 1.3.1_02-b02, green threads, nojit)
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 5
- Making hand Hand Held Devices Easier to UseMy partner comes to me every once in a while utterly flummoxed by some
hand held device for example a cell phone, a wall phone, a stereo, an
alarm clock (no kidding -- this beast is quite an intimidating device
it has over 20 buttons), and lately a digital tape recorder.
The problem is these devices have ten thousand features. All she
wanted to do was place a cell phone call or record a telephone
interview. The other features just got in the way.
There are two problems:
1. The other features distract from the basics. There are two many
buttons and too many menu items.
2. The devices have modal traps. Even if you know how to do the
simple operations, it is easy to hit the wrong button, get off in the
weeds and not know how to navigate the device back to a familiar
state.
Imagine a cellphone I could hand to my 4 year old grandson and say
"hit 7 to call me, hit 8 to call your mother, hit the red button for
an emergency" Nothing else the child could do would hurt or confuse
the phone.
Imagine I cellphone I could give to my mother. I say "When you want
to call make a call, hit the call button, use the up down arrows to
select a person from your friends list. If you get to the bottom and
it still not there, choose new person, and they will automatically be
added to the end of your list, but will drop off automatically
eventually if you don't call them.
Imagine a digital tape recorder I could give to a child. I restrict it
so that there are only buttons, record, play, fast forward, rewind.
you can't overwrite anything recorded. There is no erase button.
Imagine a PDA that starts allowing only the simplest functions.
Everything else is hidden. Once you have used and apparently mastered
those functions it offers to teach you yet another function. You can
decline or ask to lean something else. It never reveals too much of
its functionality at a time. It remembers the learning state of
several users.
A few other ideas for hand helds:
1. AC power outlets should have a DC jack built into the wall plate
using some new style plug that delivers a variety of voltages. The
tips of the prongs would receive 12, the base 1.5 with perhaps bands
for 9, 6, 3 in between. The plug on the device would normally only
tap just one voltage, but it would be free to tap all 5. There would
be no matching problem. One plug fits all. It would relieve the
clutter of ac adapters in the typical home office.
2. could it be possible to have a universal charging stand so that you
can wall mount it and put any device in it for a recharging by
induction. Another feature of the charging stand is it would also
tell and device in it the latest accurate atomic time. You could then
create a "wand" you recharge with the correct time then wave at the
microwave or any other non-portable device to update its clock.
3. Could every product be given a UPC number or equivalent so that you
can find an online manual for any device without fuss. Software too
should get such numbers so you can automatically track the latest
version, the replacement or the author. Software then could keep
track of your possessions (software and otherwise) and periodically
poll for a recall message, an important update etc.
--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm
Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
- 5
- 6
- Ideas, Making a graphical grid look like ISO viewHi, hope my question is not too abstract.
I'm drawing a square grid and I have mouse events that return
coordinates of that grid. Now I'd like to make that grid look like an
iso view. Illusion of 3D, seen from an oblique angle, as is typical in
conquest and exploration games.
Affine transform shear takes me close, but I think it's not going to get
me all the way. I think the problem is, I don't really want the
vertical lines to stay parallel, because that makes it look like the
"far end" is fatter, instead of converging to some vanishing point (The
squares in the grid should end up being trapezoidal, I think).
So two problems, 1., how to draw my grid in rectangular coords but have
it look like an iso view, and 2., how to translate the Point from the
mouse event, into the coordinates of my grid.
If Affine transform is still the way to go, I can keep studying it.
Right now I'm thinking I may actually need to work out the geometry of
the iso view, draw it explicitly, and then find the mouse coordinates by
iterating through the boundaries of my graph. This is nasty, since
AffineTransforms would make it so easy.
Maybe there's a better way I'm not thinking of, such as, instead of
bounding my grid by "lines", construct it from "shapes", and then I
could add a listener to each shape, or something like that. That sounds
treacherous too.
- 6
- JInternalFrame/JDesktopPane questionHello,
Is it possible to add a JDesktopPane to components other than
top-level components (RootPaneContainer interface implementors like
JFrame, JDialog, etc.)? I'd like to contain a set of JInternalFrames
within one side of a JSplitPane. I don't see a way to do it.
The functionality I'm looking for is a way to create a set of
components that can be dragged around within one side of a JSplitPane.
If there is another way to do that outside of JInternalFrames, I'd be
happy to hear about that as well.
Thanks,
R. Trevor
- 7
- Artificial IntelligenceRoedy Green <email***@***.com> wrote in
news:email***@***.com:
> On Wed, 21 Sep 2005 13:11:14 GMT, "JS" <james.sarjeant90
@ntlworld.com>
> wrote or quoted :
>
>>But we can fake Intelligence by using hard coded if statements,
[snip]
> I suspect living organisms are the same way. These high level
> attributes we use to describe humans and their thoughts are just
> patterns of low level flow. There is nothing in there directly that
> controls them on that level.
Exactly, there is nothing fake about hard coded if statements, unless
you want to call everything that is manmade fake.
The problem with hard coded if statements as an implementation of
intelligence isn't fakeness, it is quality. Unless there are a huge
number of if statements, you're going to notice pretty quick that this
intelligence isn't thinking very deeply on a Turing test. It is
practically impossible to make a good intelligence that way. You would
probably need billions or trillions of 'if's to make something like a
human. At the very least you would need to use a computer to write that
program for you, which is totally violating the spirit of hard coded if
statements.
- 7
- a unusual codesthe codes:
-------------------
Object[] stuff = new Object[5];
stuff[0] = "eggs";
stuff[1] = new StringBuffer( "flour" );
stuff[2] = 3.56;
stuff[3] = 'c';
stuff[4] = 123;
stuff[0]="33";
for( int i=0; i<stuff.length; i++ ) {
System.out.println( stuff[i] );
}
------------------
It seems odd.....
followings is what I guest. please tell me whether it's correct, thank
you very much
1:
what I think is because that the Object Class is any class's
superClass, so it can point to any type (right?), but in these codes it
only have Object Class's interface, not the interface which it point
to.
is it right?
2:
stuff[0]="eggs"
in this sentence,the JVM create a String object(right?), although it's
a String object and of course it has all the String object's
interface, but what the reference(stuff[0]) can access is only the
Object Class's interface.not the String interfaces(just like
concat(),charAt()....)
is it right?
3:
stuff[0]="eggs"
System.out.println( stuff[0] );
and when print it,the print function call stuff[0]'s toString()
function,and this toString() is the String object's , not the Object
Class's
is it right?
thank you very much
JTL
- 9
- Looping over arrays.Isn't it a waste of resources to loop over arrays this way:
for (i = 0; i < myArray.length; i ++) {
// do something
}
... as opposed to create a variable to hold the value of
myArray.length first, like so:
int len = myArray.length;
for (i = 0; i < len; i ++) {
// do something
}
This way the length of the array doesn't have to be recalculated on
every iteration? Or am I completely wrong?
TIA,
AJ
- 16
- reason for sporadic long full GC pause times?!?....Hello folks,
in our java business application our customer realize sporadic very
long pauses caused by full gc's.
Normaly the app runs smoothly with acceptable gc- and
full-gc-pausetimes. (gc=0.0xx sec / fullgc <=2 sec)
But sometimes during 8 hour work the occurs full gc's with 90-150
seconds (!)
which our customer complains about - of course.
In the first step I thought that our JVM-settings were wrong:
-Xms450m -Xmx450m -XX:NewSize=32m -XX:MaxNewSize=32m
-XX:SurvivorRatio=8 -classpath....
--> long full gc pauses occured sporadicaly.
I thought that the Newsize is too small -> wich implies the too big
tenured space -> which could be the reason for too longs full gc's. I
decided to use -NewRatio=4 Parameter.
And I also lowered the max. Heap size to Xmx350m, because the gcviewer
told me that the memory usage was only about 290 MB.
With the new settings
-Xms350m -Xmx350m -XX:NewRatio=4 -XX:SurvivorRatio=8 -classpath....
our customer had the same experience that sometimes the full gc's
pausetime took more than 100 sec's.
Additionally we/they relaized that the full gc freed not enough memory
so that the full gc frequency raised up to a point where no minor gc
were done - only full gc's !
Due to that I raised Xms and Xmx
-Xms512m -Xmx512m -XX:NewRatio=4 -XX:SurvivorRatio=8 -classpath....
which enables the JVM to free more memory at full gc (already tested),
but I fear this will not help to solve the sporadic problem with the
long full gc pause times at customer side.
Does anybody have an idea what could be the reason for the
extraordinary long full gc pause times?
Info btw:
customer PC's all have 1 GB RAM and the throughput of the application
was in any case >= 99,8% !
The problem with the long full gc pause times was never reproduced in
our lab / dev.-deptmnt.
Thanks in advance
Martin
- 16
- web search with summarized results, good for wireless, too.We just released a wireless search service. The wireless search
service takes the results returned by Google and gives key points of
the resulting web sites. The short key points are suitable for viewing
on wireless devices.
Check it out at:
http://www.netosprey.com
The following is an example of www.sun.com:
-----
You entered: http://www.sun.com/
Link to Text ratio: 453/914=0.49562363238512036
AME finds this page has a lot of links.
It could be an index page and talks about: Java, Sun, System,
Computing, and Products
Here is a list of main ideas presented in the page:
*** Sun's Big Web Event - Don't miss Network Computing 03-Q4 on
December 3 at 8 am PST. Sign up for an e-mail reminder today.
*** Choice on a grand scale. - Sun extends product line through
strategic alliance with AMD; plans to offer high-performance x86
systems at affordable prices.
*** The identity management leader. - Sun's planned acquisition of
Waveset aims to inject the Java EnterpriseSystem with superior network
identitycapabilities.
*** Sun Signs Agreement with CSSC - Java Desktop System to be
established as the foundation for China's fast-growing IT industry.
*** Contact |Company Info |Employment |Privacy |Terms of Use
|Trademarks
-----
Check it out at:
http://www.netosprey.com
Steve
- 16
- question about keeping the GUI and logic separateHello,
I have a question about keeping logic/processing code off of the GUI.
In a couple of other languages I'm familiar with, there is usually a
method called FindComponent which will iterate through a form and get
the component matching the name in the argument.
For example, in VS.NET lets say I have a grid (table) on a form, the
form represents one class. I then put the code for getting and
processing data in another class. After any processing occurs (and
the results are placed in a dataset), I need to bind the dataset to
the grid. But the grid doesn't have knowledge of where the dataset
came from... so how does the data get shoveled in there?
In the data processing class, there's a local variable of grid type
and it's gets bound to the grid in the form, like so (sorry about the
VB):
Class SomeClass
Sub doSomething(ByVal c As Component)
Dim localGridView as GridView
Dim localDataSet as DataSet
' MyGrid lives on Form1
localGridView = c.FindComponent("MyGrid")
localGridView.DataSource = localDataSet
' So even though the GUI hasn't a clue as to what is going on, the
current data is now displayed to the user.
localGridView.DataBind()
End Sub
End Class
Does Java have an equivalent of FindComponent, or a something similar
to the code snip above?
I'm using Java 6 here. I did try looking at c.getComponent() but
there's only one valid index... 0 and it represents the
javax.swing.JRootPane. Anything after 0 throws an index out of bounds
error. There are 3 JButtons and 1 JList on the panel. I want to add
some strings to the JList...
public class MyGUI() extends JFrame
{
GUIUtils u = new GUIUtils();
public MyGUI()
{
//
// snip
//
myButton.addActionListener (new ActionListener()
{
public void actionPerformed (ActionEvent e)
{
try
{
u.doSomething(MyGUI.this);
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
}
});
}
and...
public class GUIUtils
{
public void doSometing(Container c) throws IOException
{
listModel = new DefaultListModel();
listModel.addElement(value);
// I want to put the listmodel in the JList now but how do I get
this code to know about the JList in MyGUI?
}
}
Suggestions are greatly appreciated.
Thanks!
|
| Author |
Message |
Tom Anderson

|
Posted: 2008-6-2 23:18:00 |
Top |
java-programmer, Comparing two long numbers
On Mon, 2 Jun 2008, Daniele Futtorovic wrote:
> On 2008-06-02 13:22 +0100, Lew allegedly wrote:
>> Lew wrote:
>>>> Why do you use either "d" or "D"? Is it something you always put on
>>>> double constants, or just for potentially ambiguous situations? If the
>>>> latter, how do you assess ambiguity?
>>
>> John B. Matthews wrote:
>>> I don't use either "d" or "D"; I use "d", but I have to read other
>>> people's "D"s. Presbyopia comes to us all. :-)
>>
>> Most people don't bother with either "d" or "D" in Java double constants.
>> I never have to read other people's "D" in Java code; I don't think I've
>> ever encountered a double suffix on a constant in any professional Java
>> code.
>
> double athird = 1d / 3; ?
Urgh. Now this:
double farthing = 1d / 4 ;
is at least numismatically accurate, but won't compile after 1960!
tom
--
Eat whip you steroid wall-bashing lug-head! -- The Laird
|
| |
|
| |
 |
Tom Anderson

|
Posted: 2008-6-2 23:18:00 |
Top |
java-programmer >> Comparing two long numbers
On Mon, 2 Jun 2008, Daniele Futtorovic wrote:
> On 2008-06-02 13:22 +0100, Lew allegedly wrote:
>> Lew wrote:
>>>> Why do you use either "d" or "D"? Is it something you always put on
>>>> double constants, or just for potentially ambiguous situations? If the
>>>> latter, how do you assess ambiguity?
>>
>> John B. Matthews wrote:
>>> I don't use either "d" or "D"; I use "d", but I have to read other
>>> people's "D"s. Presbyopia comes to us all. :-)
>>
>> Most people don't bother with either "d" or "D" in Java double constants.
>> I never have to read other people's "D" in Java code; I don't think I've
>> ever encountered a double suffix on a constant in any professional Java
>> code.
>
> double athird = 1d / 3; ?
Urgh. Now this:
double farthing = 1d / 4 ;
is at least numismatically accurate, but won't compile after 1960!
tom
--
Eat whip you steroid wall-bashing lug-head! -- The Laird
|
| |
|
| |
 |
Daniele Futtorovic

|
Posted: 2008-6-2 23:31:00 |
Top |
java-programmer >> Comparing two long numbers
On 2008-06-02 17:17 +0100, Tom Anderson allegedly wrote:
> On Mon, 2 Jun 2008, Daniele Futtorovic wrote:
>> double athird = 1d / 3; ?
>
> Urgh. Now this:
>
> double farthing = 1d / 4 ;
>
> is at least numismatically accurate, but won't compile after 1960!
Yet more puzzling:
single farthing = 1p / 4 ;
But it won't compile at all!! Sheesh. I wonder who's designing those
"computer language" things.
--
DF.
to reply privately, change the top-level domain
in the FROM address from "invalid" to "net"
|
| |
|
| |
 |
Nigel Wade

|
Posted: 2008-6-2 23:58:00 |
Top |
java-programmer >> Comparing two long numbers
Daniele Futtorovic wrote:
> On 2008-06-02 17:17 +0100, Tom Anderson allegedly wrote:
>> On Mon, 2 Jun 2008, Daniele Futtorovic wrote:
>>> double athird = 1d / 3; ?
>>
>> Urgh. Now this:
>>
>> double farthing = 1d / 4 ;
>>
>> is at least numismatically accurate, but won't compile after 1960!
It should compile, but it ought to throw a IllegalTenderException for dates
after 1960.
>
> Yet more puzzling:
>
> single farthing = 1p / 4 ;
>
> But it won't compile at all!!
That statement is both semantically and chronologically incorrect. Hardly
surprising it won't compile.
A farthing was not equal to 1p/4, nor could ever have been 1p/4. The farthing
was retired (1960) long before decimalisation when the new penny came into
circulation (1971). It was, as Tom said, equal to 1d/4.
--
Nigel Wade
|
| |
|
| |
 |
Daniele Futtorovic

|
Posted: 2008-6-3 0:20:00 |
Top |
java-programmer >> Comparing two long numbers
On 2008-06-02 17:58 +0100, Nigel Wade allegedly wrote:
> Daniele Futtorovic wrote:
>> Yet more puzzling:
>>
>> single farthing = 1p / 4 ;
>>
>> But it won't compile at all!!
>
> That statement is both semantically and chronologically incorrect. Hardly
> surprising it won't compile.
>
> A farthing was not equal to 1p/4, nor could ever have been 1p/4. The farthing
> was retired (1960) long before decimalisation when the new penny came into
> circulation (1971). It was, as Tom said, equal to 1d/4.
Ah, right, the old abbreviation for pence was "d". Damn.
But one quarter is 1/4: decimalisation don't enter into it. Not unless
you state 1/4 = 0.25.
--
DF.
to reply privately, change the top-level domain
in the FROM address from "invalid" to "net"
|
| |
|
| |
 |
Daniel Pitts

|
Posted: 2008-6-3 0:34:00 |
Top |
java-programmer >> Comparing two long numbers
Arne Vajh酶j wrote:
> Mark Space wrote:
>> Arne Vajh酶j wrote:
>>> In Fortran a d0 is necessary to make it a double, but ...
>>
>> And I think the same in C, right?
>>
>> double n = 1.5d;
>>
>> So he probably uses "d" out of habit or for folks who commonly switch
>> between Java and other languages. No chance of getting it wrong for a
>> given language if you just always get in the habit of adding it.
>
> I am pretty sure that C also has default double and explicit f
> for float.
>
> Arne
I believe 1.5d is a compiler error in C.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
|
| |
|
| |
 |
Tom Anderson

|
Posted: 2008-6-3 0:53:00 |
Top |
java-programmer >> Comparing two long numbers
On Mon, 2 Jun 2008, Daniele Futtorovic wrote:
> On 2008-06-02 17:58 +0100, Nigel Wade allegedly wrote:
>> Daniele Futtorovic wrote:
>>> Yet more puzzling:
>>>
>>> single farthing = 1p / 4 ;
>>>
>>> But it won't compile at all!!
>>
>> That statement is both semantically and chronologically incorrect. Hardly
>> surprising it won't compile.
>>
>> A farthing was not equal to 1p/4, nor could ever have been 1p/4. The
>> farthing was retired (1960) long before decimalisation when the new
>> penny came into circulation (1971). It was, as Tom said, equal to 1d/4.
>
> Ah, right, the old abbreviation for pence was "d". Damn.
>
> But one quarter is 1/4: decimalisation don't enter into it. Not unless
> you state 1/4 = 0.25.
The point is that on decimalisation, the letter for 'penny' changed (as
did the value of the coin) - the pre-decimal penny is d, the decimal penny
is p. 1p/4 would be a quarter of a decimal penny, a denomination which has
never existed.
tom
--
Eat whip you steroid wall-bashing lug-head! -- The Laird
|
| |
|
| |
 |
Daniele Futtorovic

|
Posted: 2008-6-3 1:16:00 |
Top |
java-programmer >> Comparing two long numbers
On 2008-06-02 18:52 +0100, Tom Anderson allegedly wrote:
> On Mon, 2 Jun 2008, Daniele Futtorovic wrote:
>
>> On 2008-06-02 17:58 +0100, Nigel Wade allegedly wrote:
>>> Daniele Futtorovic wrote:
>>>> Yet more puzzling:
>>>>
>>>> single farthing = 1p / 4 ;
>>>>
>>>> But it won't compile at all!!
>>>
>>> That statement is both semantically and chronologically incorrect.
>>> Hardly
>>> surprising it won't compile.
>>>
>>> A farthing was not equal to 1p/4, nor could ever have been 1p/4. The
>>> farthing was retired (1960) long before decimalisation when the new
>>> penny came into circulation (1971). It was, as Tom said, equal to 1d/4.
>>
>> Ah, right, the old abbreviation for pence was "d". Damn.
>>
>> But one quarter is 1/4: decimalisation don't enter into it. Not unless
>> you state 1/4 = 0.25.
>
> The point is that on decimalisation, the letter for 'penny' changed (as
> did the value of the coin) - the pre-decimal penny is d, the decimal
> penny is p. 1p/4 would be a quarter of a decimal penny, a denomination
> which has never existed.
I see. Thanks for the clarification.
--
DF.
to reply privately, change the top-level domain
in the FROM address from "invalid" to "net"
|
| |
|
| |
 |
Lew

|
Posted: 2008-6-3 8:01:00 |
Top |
java-programmer >> Comparing two long numbers
Daniele Futtorovic wrote:
> On 2008-06-02 18:52 +0100, Tom Anderson allegedly wrote:
>> On Mon, 2 Jun 2008, Daniele Futtorovic wrote:
>>
>>> On 2008-06-02 17:58 +0100, Nigel Wade allegedly wrote:
>>>> Daniele Futtorovic wrote:
>>>>> Yet more puzzling:
>>>>>
>>>>> single farthing = 1p / 4 ;
>>>>>
>>>>> But it won't compile at all!!
>>>>
>>>> That statement is both semantically and chronologically incorrect.
>>>> Hardly
>>>> surprising it won't compile.
>>>>
>>>> A farthing was not equal to 1p/4, nor could ever have been 1p/4. The
>>>> farthing was retired (1960) long before decimalisation when the new
>>>> penny came into circulation (1971). It was, as Tom said, equal to 1d/4.
>>>
>>> Ah, right, the old abbreviation for pence was "d". Damn.
>>>
>>> But one quarter is 1/4: decimalisation don't enter into it. Not
>>> unless you state 1/4 = 0.25.
>>
>> The point is that on decimalisation, the letter for 'penny' changed
>> (as did the value of the coin) - the pre-decimal penny is d, the
>> decimal penny is p. 1p/4 would be a quarter of a decimal penny, a
>> denomination which has never existed.
>
> I see. Thanks for the clarification.
Also, 'single' is not a Java keyword.
--
Lew
|
| |
|
| |
 |
Lew

|
Posted: 2008-6-3 8:02:00 |
Top |
java-programmer >> Comparing two long numbers
Lew wrote:
>> The compiler does not require a "d" suffix. By itself, 1.0 is a double
>> constant in Java.
>> <http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.2>
John B. Matthews wrote:
> No doubt, but consider a rational constant. I slightly prefer the
> second. You?
>
> private static final double ASPECT_RATIO = 0.7;
> private static final double ASPECT_RATIO = 7d / 10;
> private static final double ASPECT_RATIO = 7.0 / 10.0;
I prefer the first and third of your examples.
--
Lew
|
| |
|
| |
 |
Daniele Futtorovic

|
Posted: 2008-6-3 8:24:00 |
Top |
java-programmer >> Comparing two long numbers
On 2008-06-03 02:00 +0100, Lew allegedly wrote:
> Also, 'single' is not a Java keyword.
No shit. Was supposed to be a joke. Y'all no fun anymore.
--
DF.
to reply privately, change the top-level domain
in the FROM address from "invalid" to "net"
|
| |
|
| |
 |
Lew

|
Posted: 2008-6-3 8:28:00 |
Top |
java-programmer >> Comparing two long numbers
Daniele Futtorovic wrote:
> On 2008-06-03 02:00 +0100, Lew allegedly wrote:
>> Also, 'single' is not a Java keyword.
>
> No shit. Was supposed to be a joke. Y'all no fun anymore.
Ah.
:-}
--
Lew
|
| |
|
| |
 |
QXJuZSBWYWpow7hq

|
Posted: 2008-6-3 10:07:00 |
Top |
java-programmer >> Comparing two long numbers
Daniele Futtorovic wrote:
> On 2008-06-02 13:22 +0100, Lew allegedly wrote:
>> Lew wrote:
>>>> Why do you use either "d" or "D"? Is it something you always put on
>>>> double constants, or just for potentially ambiguous situations? If
>>>> the latter, how do you assess ambiguity?
>>
>> John B. Matthews wrote:
>>> I don't use either "d" or "D"; I use "d", but I have to read other
>>> people's "D"s. Presbyopia comes to us all. :-)
>>
>> Most people don't bother with either "d" or "D" in Java double
>> constants. I never have to read other people's "D" in Java code; I
>> don't think I've ever encountered a double suffix on a constant in any
>> professional Java code.
>
> double athird = 1d / 3; ?
>
> Granted, "1." would be the same. But haven't you ever encountered it?
I am sure that I would use 1.0, but out of all the Java developers
there has to be some that prefer 1d.
Arne
|
| |
|
| |
 |
QXJuZSBWYWpow7hq

|
Posted: 2008-6-3 10:08:00 |
Top |
java-programmer >> Comparing two long numbers
Daniel Pitts wrote:
> Arne Vajh酶j wrote:
>> Mark Space wrote:
>>> Arne Vajh酶j wrote:
>>>> In Fortran a d0 is necessary to make it a double, but ...
>>>
>>> And I think the same in C, right?
>>>
>>> double n = 1.5d;
>>>
>>> So he probably uses "d" out of habit or for folks who commonly switch
>>> between Java and other languages. No chance of getting it wrong for
>>> a given language if you just always get in the habit of adding it.
>>
>> I am pretty sure that C also has default double and explicit f
>> for float.
>>
> I believe 1.5d is a compiler error in C.
Yet another variation.
Arne
|
| |
|
| |
 |
John B. Matthews

|
Posted: 2008-6-3 14:24:00 |
Top |
java-programmer >> Comparing two long numbers
In article <email***@***.com>,
Lew <email***@***.com> wrote:
> Lew wrote:
> >> The compiler does not require a "d" suffix. By itself, 1.0 is a double
> >> constant in Java.
> >> <http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.2>
>
> John B. Matthews wrote:
> > No doubt, but consider a rational constant. I slightly prefer the
> > second. You?
> >
> > private static final double ASPECT_RATIO = 0.7;
> > private static final double ASPECT_RATIO = 7d / 10;
> > private static final double ASPECT_RATIO = 7.0 / 10.0;
>
> I prefer the first and third of your examples.
Wait, I forgot ...ASPECT_RATIO = Rational.doubleValue(7, 10); :-)
John
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
|
| |
|
| |
 |
Andreas Leitgeb

|
Posted: 2008-6-3 14:48:00 |
Top |
java-programmer >> Comparing two long numbers
John B. Matthews <email***@***.com> wrote:
>> > private static final double ASPECT_RATIO = 0.7;
>> > private static final double ASPECT_RATIO = 7d / 10;
>> > private static final double ASPECT_RATIO = 7.0 / 10.0;
> Wait, I forgot ...ASPECT_RATIO = Rational.doubleValue(7, 10); :-)
Why final, anyway? As if the eye were never to move... :-)
|
| |
|
| |
 |
John B. Matthews

|
Posted: 2008-6-3 18:30:00 |
Top |
java-programmer >> Comparing two long numbers
In article <email***@***.com>,
Andreas Leitgeb <email***@***.com> wrote:
> John B. Matthews <email***@***.com> wrote:
> >> > private static final double ASPECT_RATIO = 0.7;
> >> > private static final double ASPECT_RATIO = 7d / 10;
> >> > private static final double ASPECT_RATIO = 7.0 / 10.0;
> > Wait, I forgot ...ASPECT_RATIO = Rational.doubleValue(7, 10); :-)
>
> Why final, anyway? As if the eye were never to move... :-)
It was an internal proportion for rendering a component that filled its
container. The container was responsible for assuming a pleasing aspect.
John
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
|
| |
|
| |
 |
Andreas Leitgeb

|
Posted: 2008-6-3 20:59:00 |
Top |
java-programmer >> Comparing two long numbers
John B. Matthews <email***@***.com> wrote:
> It was an internal proportion for rendering a component that filled its
> container. The container was responsible for assuming a pleasing aspect.
Perhaps, 0.61803398875 would have been even more pleasing than 0.7 :-)
|
| |
|
| |
 |
John B. Matthews

|
Posted: 2008-6-3 23:16:00 |
Top |
java-programmer >> Comparing two long numbers
In article <email***@***.com>,
Andreas Leitgeb <email***@***.com> wrote:
> John B. Matthews <email***@***.com> wrote:
> > It was an internal proportion for rendering a component that filled its
> > container. The container was responsible for assuming a pleasing aspect.
>
> Perhaps, 0.61803398875 would have been even more pleasing than 0.7 :-)
Yes, but surely you mean 2 / (1 + Math.sqrt(5d))! Clearly there is an
immanent need for Math.PHI :-)
John
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
|
| |
|
| |
 |
Andreas Leitgeb

|
Posted: 2008-6-4 1:09:00 |
Top |
java-programmer >> Comparing two long numbers
John B. Matthews <email***@***.com> wrote:
>> Perhaps, 0.61803398875 would have been even more pleasing than 0.7 :-)
> Yes, but surely you mean 2 / (1 + Math.sqrt(5d))! Clearly there is an
> immanent need for Math.PHI :-)
I meant (Math.sqrt(5.)-1)/2, which is theoretically the same, but
numerically more stable, since the divisor is simpler.
But then it would be Math.PHI, and at least as exact as each of the
formulae, if not better than both. :-)
|
| |
|
| |
 |
John B. Matthews

|
Posted: 2008-6-4 2:06:00 |
Top |
java-programmer >> Comparing two long numbers
In article <email***@***.com>,
Andreas Leitgeb <email***@***.com> wrote:
> John B. Matthews <email***@***.com> wrote:
> >> Perhaps, 0.61803398875 would have been even more pleasing than 0.7 :-)
> > Yes, but surely you mean 2 / (1 + Math.sqrt(5d))! Clearly there is an
> > immanent need for Math.PHI :-)
>
> I meant (Math.sqrt(5.)-1)/2, which is theoretically the same, but
> numerically more stable, since the divisor is simpler.
> But then it would be Math.PHI, and at least as exact as each of the
> formulae, if not better than both. :-)
You're right: I inverted but didn't simplify! But isn't
(Math.sqrt(5.)-1)/2 equal to 1 / phi?
John
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- turn off multiref in Axis(SOAP)Is there any possibilities to turn off references in soap envelope.
I would like to have response axis format equivalent old soap format.
thanks for help
bastek
- 2
- [OT] gov't sponsored drug development"Peter Koehlmann" <email***@***.com> wrote:
> Tim Tyler wrote:
>> Development of life-saving drugs would be sponsored by the government.
> What universe was it you said you live in?
Oh, probably the one where in the US at least, the National Institutes
of Health do exactly that, every business day.
Tim lives in one of the civilized countries where they have Public
Health for all, and of course there, the government is money ahead
if new drugs cut down the total balanced cost of treating the ill and
compensating for the other disbenefits to society that illness causes,
even at the tax base level, and if they had any brains would realize
that and fund research accordingly.
xanthian.
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
- 3
- Baffling class not found problemHello, I'm using Java 1.3 with WebLogic 5.1 on Solaris. I have these
files:
cms/system/CMSException.class
cms/system/Constants.class
cms/system/InitServlet.class
cms/system/Log.class
When I include this line on my JSP page
<%@ page import="cms.system.*" %>
everything compiles fine. As does this line
<%@ page import="cms.*" %>
but when I try
<%@ page import="cms.system.Constants" %>
(r using any of the 4 class names above) I get the error:
Compilation of '/tmp/support/jsp_servlet/_www/__temp.java' failed:
/tmp/support/jsp_servlet/_www/__temp.java:16: Class
cms.system.Constants not found in import.
probably occurred due to an error in /www/temp.jsp line 1:
<%@ page import="cms.system.Constants" %>
How can this be? The perms on the files above are all 775. Can anyone
think of an explanation for why these files can't be found?
Thanks, - Dave
- 4
- can't create BufferedImageI am trying to create a BifferedImage and Graphics2D associated with a
JPanel. I understand that the JPanel must be displayable else the
createImage method may return null. However in my stub program below I
always get null returned from createGraphics. I obviously am missing
something but I can't figure out what. If the program below is run
without a runline parameter it does not attempt to create a
BufferedImage and it runs OK. If it is run with a runline parameter it
throws an exception because bh is null. Why?
Jay
public class Test extends javax.swing.JFrame {
private static String[] opt = null;
public Test() {
init();
}
void init() {
javax.swing.JPanel jContentPane = new javax.swing.JPanel();
setContentPane(jContentPane);
setSize(450, 350);
javax.swing.JPanel graphPanel = new javax.swing.JPanel();
java.awt.Dimension s = new java.awt.Dimension(400, 300);
graphPanel.setPreferredSize(s);
getContentPane().add(graphPanel, null);
graphPanel.addNotify();
s = graphPanel.getPreferredSize();
System.err.println("Is JPanel=" +
(graphPanel instanceof javax.swing.JPanel) +
" " + s.width + "x" + s.height + " Displayable=" +
graphPanel.isDisplayable() + " Headless= " +
java.awt.GraphicsEnvironment.isHeadless());
if(opt!=null && opt.length>0) {
java.awt.image.BufferedImage bh =
(java.awt.image.BufferedImage)graphPanel.createImage(
s.width, s.height);
java.awt.Graphics2D bufh = bh.createGraphics();
}
}
public static final void main(String[] argv) {
opt = argv;
Test test = new Test();
test.setVisible(true);
}
}
- 5
- For loop not working from static methodI have a JSP that outputs 10 links and it works great but want to cut
down on the scriptlet lines in my JSP.
Now I want to put the for loop that outputs the 10 links into a source
file and call the class in my JSP using just one line scriptlet.
Here is what my current JSP looks like where it outputs the 10 links:
<jsp:useBean id="pageinfo" class="storm.Pageinfo" scope="session" />
.....
<%
if (pageinfo!=null)
{
for(int i=0;i < 10;i++)
{
out.println("<a href=moveto.jsp?inpage=" + i + ">" + i + "</
a>");
}
}
%>
Now my attempt to put it in a class outputs only 1 link instead of 10.
Source code for the Java class:
package storm;
import storm.*;
public class PageUtil
{
public static String theMethod(Pageinfo pageinfo)
{
if (pageinfo!=null)
{
for(int i=0;i < 10;i++)
{
return "<a href=moveto.jsp?inpage=" + i + ">" + i +
"</a>";
}
}
return "";
}
}
JSP scriptlet calling the static method:
<%= PageUtil.theMethod(pageinfo) %>
Please advise how I can get this to work. I am using Tomcat 4.1.27
and dont have JSTL.
- 6
- panel question.."Frances" <email***@***.com> wrote in message
news:4317337c$0$18646$email***@***.com...
<snipped />
> Sunde, we finally managed to connect to server.. thank you very much for
> all your help, very much appreciated.. Frances
You never said...
Did your original code call one of the applets methods from JavaScript?
...or was it something else?
I'm just curious to what was wrong...
--
Dag.
- 7
- How do I make a simple password field....more.I want to password protect the continued running of a section of javascript.
What I need is for the user to see a login field, they type a code in, if it
is good, the script continues, if bad, it stops dead.
I would like to base the password on julian date.
Also, how do I time out a group of statements after a preset amount of time
like 1 minute or so.
I am not a Java programmer, but if examples are shown, I can usually figure
out the specific details.
THANKS in advance.
- 8
- GridBagLayout and JMenuBar problemsHere's another interesting one. I looked on the Bug Parade to see if
this was present, but rapidly drowned in the sea of totally unrelated
results I got back from the brain dead search capabilities.
I built up a JPanel using GridBagLayout and various components. Works
fine; I'm quite used to GridBagLayout and its quirks. I'm using the
Java look and feel with native decorations turned off, so GridBagLayout
respects my panel's minimum size constraints.
I had been testing this layout in a JFrame without a JMenuBar, just to
validate the layout. Now when I added a JMenuBar to the JFrame, the
layout screws up when I resize the panel down to its smallest size.
It's as though the GridBagLayout does not take the JMenuBar's dimensions
into account when resizing happens. In my case, a couple of buttons
shrink in height, a text field bizarrely grows to 1.5X height, and
another text field overlaps it. None of these problems show up unless
the menu bar is in place.
Again: a known bug? Or should I submit it?
If there's any interest I'll whittle my code down to a SSCCE. Then I'll
try it with native window decorations turned on to see if that's where
the problem lies.
Laird
- 9
- Whatever happened to PvdL?My curiosity about Hotjava now sated, what of Peter van der Liden? I recall
that he used to be pretty active on Usenet and quite a prolific author and
Java advocate.
As I recall he used to author the Java FAQ (which now 404's). I liked his
writing style (dating to the ugly fish book) and the Just Java series. The
6th edition came out in 2004 and no errata has published since January
2005.
Is Mr. van der Liden still active in the Java community? I realize he's no
longer with Sun and without treading into personal matters, did he have a
falling out with the people there? In spite of being published by Sun, his
Java books did contain quite a few barbs about misfeatures in the language.
- 10
- jsp servlet code seperation confusionI posted this on the .help NG but I believe you folks could probably
provide more of an accurate answer considering the help group is
targeted towards true beginners.
Okay, where I am employeed I have the options of programming with
Microsoft Technologies and Java specifically J2EE. I have been
investigating the task of learning Java for about the last 3 to 4
months. I am a ASP.Net developer fulltime at work with C#. I was new to
OOP when I started into .Net about a year ago and am getting better.
However, our corporation uses Java as a National standard and I am
looking to advance some day and need to learn Java. Furthermore, where I
live, KY there are very few jobs for technologies other than .Net and
Java. No PHP or ColdFusion.
In the last couple of years this code seperation theory has overloaded
the programming world. .Net does it with what's called code behind. In
my research of Java the only things I see that reference code seperation
is servlets (I am sure J2EE and EJB contribute also). However,
everything I have read on servlets reference outputing HTML back to the
browser via the HttpServletResponse and Request objects.
My question, why in the world do they consider outputting HTML back to a
browser via a servlet considered code seperation. Furthermore, it
seems very time consuming and difficult to hand code complex layouts in
HTML and incorporate/format it for a servlet.
Can someone please explain or direct me to a resource where I can
understand why using servlets at any point in an application would be
better than jsp or even applets? Sometimes it's hard enough to design
complex layouts with the assistance Dreamweaver for example.
Thanks for any insight you can provide, I have read hundreds of pages of
information concerning this and trying to compare it with the my current
knowledge in the .Net world.
Marty U.
- 11
- J2ME, How to minimize a program ?Thank you so much for the information I didn't know.
But, for Sony Ericsson cells, we can press back button ( like the
symbol of inverse Enter ) to exit ( not destroy ) program.
For SmartPhone - P910i, we can run other funtion very easily ( we don't
have to implement it )
I found a cheat method that could do this.
public Form f;
....
....
// Do not new a Form for f
display.setCurrent(f); // minimum program :p
// I don't know why, the compiler pass it, and we can find it is work
on cell.
- 12
- jboss and Workflow??I'm work with Jboss, and I'd use Workflow on Jboss server. Is Anyone working about this problem? Can anyone give me a tutorial or an example???
- 13
- database connection pooling in tomcat 3.3.1Hi,
I have a webapp which uses database connection pooling setup just like
the tomcat how-to suggests. But, I can't seem to get it to work on
tomcat 3.3.1. I couldn't even find any how-tos or guidances on it
anywhere. Is it supported ?
I get a javax.naming.NoInitialContextException: error when I set it up
in the conf/app-myapps.xml like the 3.3.1 doco suggests.
Appreciate any help on this.
Regards,
Lenine
- 14
- Grab common name from https://[ip]Hello,
I checked around on here a bit, and was unable to find an answer to
this one by searching for the error message. I'm hoping someone here
can help me with this issue.
I am attempting to gather the common name from an SSL certificate for a
given IP address. Following is the code I am using thus far (two
classes being used):
IP_Justification.java:
import java.net.*; //for https connection
import java.io.*; //for input parsing
import javax.net.ssl.HttpsURLConnection;
public class IP_Justification
{
private String IP; //IP address to search
private String domain; //common name returned by viewing IP via
https://ip
//default constructor
public IP_Justification()
{
throw new IllegalArgumentException("Please provide IP and domain");
}
//create with IP provided
public IP_Justification(String ip)
{
IP = ip;
domain = "";
}
public void getDomain() throws IOException
{
String urlToCheck = "https://" + IP;
URL techURL = new URL(urlToCheck);
System.out.println("URL created: " + techURL);
HttpURLConnection techUrlConn =
(HttpURLConnection)techURL.openConnection();
System.out.println("HttpURLConnection created" + techUrlConn + "\n");
techUrlConn.connect();
}
}
IPJustMain.java
import java.io.*;
public class IPJustMain
{
public static void main(String[] args) throws IOException
{
IP_Justification testing;
testing = new IP_Justification("64.233.167.99");
testing.getDomain();
try
{
}
catch(Exception e)
{
System.out.println("Start of output - Exception block");
System.out.println(e.getMessage());
System.out.println("End of output - Exception block");
}
}
}
Following is the output received when running IPJustMain:
URL created: https://64.233.167.99
HttpURLConnection
createdsun.net.www.protocol.https.DelegateHttpsURLConnection:h
ttps://64.233.167.99
Exception in thread "main" java.io.IOException: HTTPS hostname wrong:
should be
<64.233.167.99>
at
sun.net.www.protocol.https.HttpsClient.checkURLSpoofing(HttpsClient.j
ava:490)
at
sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:
415)
at
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect
(AbstractDelegateHttpsURLConnection.java:170)
at
sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLCon
nectionImpl.java:133)
at IP_Justification.getDomain(IP_Justification.java:54)
at IPJustMain.main(IPJustMain.java:15)
Press any key to continue . . .
I fully expect to have an exception thrown, and am hoping to be able to
parse that for the information I require. The problem I am running
into is the exception itself:
Exception in thread "main" java.io.IOException: HTTPS hostname wrong:
should be
<64.233.167.99>
It seems to be responding with the URL I pass to it, and not the common
name for the SSL at the specified IP address.
Anyone happen to know if there is a way around this or if my code is
flawed in someway?
Thanks for any help that can be provided!
- 15
- 2 extendsDale King wrote:
> The Wogster wrote:
>
>> Thomas G. Marshall wrote:
>>
>>> The Wogster coughed up:
>>>
>>>> Irlan agous wrote:
>>>>
>>>> It's like the goto, it's legal in C, but the only times I have seen it
>>>> used, were because someone had programmed themselves into a corner.
>
>
> In C there were some cases where it was necessary/mad the code clearer.
> Most of those cases in Java have other constructs that eliminate the
> need for an arbitrary goto. Exceptions, labelled break and continue
> eliminate most of the cases for goto from C. But since C doesn't have
> those you are forced to use goto or over complicate the code.
>
>> With languages that have richly designed looping and redirection
>> constructs, you shouldn't need the goto. I didn't say it was always
>> to be avoided, just that when you feel the need to use goto (except
>> maybe in Gee Whiz Basic), it's usually a pretty good indicator that
>> the code design is lacking.
>
>
> That design as you said could be the design of the language and not
> necessarily the design of the program. Or are you one of those anti-goto
> that also disagrees with goto-like constructs like break, continue, and
> exceptions?
Uh no, because those leave control with the language. Most people who
defend the goto so vehemently,are, with modern languages like Java,
simply are using it to emulate something else available within the language.
Let's see, in the last 10 years, I have written about 1,000,000 lines of
C code, the number of actual goto's in there, none. During that time, I
viewed probably 40,000,000 more lines, which contained maybe 20 gotos.
Shows how little goto is actually needed. Of those 5, were code that
was complex trying to do something simple, usually the reason I was
looking at it, was because it wasn't working (poor design). Five more
were instances where you had the jack-of-all-procedures, where the
programmer had written a bunch of procedures in one block of code (again
poor design). They used goto to make the thing work. The remaining
ones, were places where the programmer had written themselves into a
corner, and under pressure of getting the thing to work, used goto to
bail out (again poor design).
W
|
|
|