| An efficient computation idea. Please comment |
|
 |
Index ‹ java-programmer
|
- Previous
- 3
- CVS checkout doesn't work in Eclipse v3.0.1Hi,
Since the CVS functionality of NetBeans doesn't appear to work for
me, I'm trying Eclipse. However, the CVS functionality of Eclipse
doesn't appear to work either. When I try to do a CVS checkout in
Eclipse, a "project" does get created in my workspace, but the
contents of the CVS modules aren't actually in the project. Now, the
contents of the module are only directories to this point, because I
was looking to work on the module with Eclipse. Should this be a
problem? Should I add a least one file to the project before Eclipse
will properly checkout the module with all its subdirectories?
Thanks,
Jason
- 4
- java.sql.SQLException: ORA-00020: maximum number of processes (100) exceededHello Friends,
I am getting the following error.
java.sql.SQLException: ORA-00020: maximum number of processes (100)
exceeded
I am closing all my resultsets and all my connections in the try
block.
should i close ResultSets and Connections in the catch block aswell?.
or the problem is due to the connection pool settings in weblogic or
on the oracle side instead of in my application.
Thanks in Advance
s
- 4
- Running a servlet with TomcatHi,
When I use the following URL in Internet Explorer:
http://localhost/servlet/HelloWorldExample
I get an error message:
-----8<------------
HTTP Status 404 - /servlet/HelloWorldExample
--------------------------------------------------------------------------------
type Status report
message /servlet/HelloWorldExample
description The requested resource (/servlet/HelloWorldExample) is not
available.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.17
-----8<------------
I have the HelloWorldExample.class file in
C:\Tomcat5.5\webapps\ROOT\WEB-INF\classes.
Can anyone help me please?
Best regards,
Matheas Manssen
- 4
- In Swing, using the RTFEditorKit, how to copy/cut Formatting *and* text to the Clipboard?Hi Folks:
Any idea on the best approach to support copy/cut of all style/formatting as
well as plain text for a JTextPane? I googled quite a bit and located a
word processing program that supports JTextPane but they specifically
mention it only places "plain text" to the Clipboard and ignores the
formatting information when transfering.
I was thinking about implementing the Transferable interface and using the
Clipboard.setContents(..) method but I'm not sure yet by which procedure I
implement the getTransferData() as it wants to return an Object. I could
use a byte[] stream and return a ByteArrayOutputStream who's contents would
be filled with the Document's data (ie, plain text *and* the control/style
information). I just don't know if that would work yet but I plan to try
that.
Seems like there's very little (if anything) mentioned in the sun
developer's forum on how to do this as well as in google...
First of all, is Java's support for RTF still somewhat "primative"??? I
have a full blown word processor going which looks like Word and supports
font changes, size changes, find/replace operations, etc... It's just that
the cut/copy only transfers the plain text (despite my attempts to call
setContentType("text/rtf")) to the clipboard and not the style information.
thanks for any insight, Theron
- 4
- AspectJ: solution to Java's repetitiveness?thufir wrote:
> On Sat, 26 Apr 2008 06:51:43 -0400, Lew wrote:
>
>>> attrib_writer :foo, :bar #getter and setter for foo and bar attributes,
>>> #getter setter methods aren't actually written
>> Well, Java cannot do that because it's not in the language definition
>> and because the colon character already serves three other purposes in
>> Java.
>
> That Ruby syntax doesn't work in Java isn't the point at all.
>
>> I would just go with getters/setters. What's the big deal? My IDEs
>> generate them for me, so there's no typing, and it sure helps
>> maintainers to see them.
>>
>> It would be a huge waste of energy to retrofit Java with such a feature.
>
> The point is that getter/setter methods are boilerplate. Adding such a
> feature to Java would be worth it, and Java is constantly in flux.
>
>
> -Thufir
Can't you just add a (custom) annotation, e.g. "@JavaBean", and use
apt to generate the getters/setters? (Or possibly the newer
javax.annotation* stuff?) You could add options to such an
annotation e.g., read-only.
Then add the one extra line in your ant script to build code.
Note JavaEE defines many such annotations, including for an
MX Bean. Adding a standard annotation "@JavaBean" doesn't seem
like it would be that much effort, for a large convenience payoff.
<waffle>
Like Lew I use an IDE that does that for me. Still, I don't like
dependencies on particular tools that provide special features, if
the language could easily support them with little effort.
OTOH as others have pointed out in previous threads, the JavaBean
spec is rarely used, so maybe adding more standard annotations
isn't worth it.
If the OP thinks it should be used, create or modify a JSR for this
feature; if enough others agree it will be added.
</waffle>
-Wayne
- 5
- Critical Problem with Tomcat 3.3.1 and SSLHello,
I am having a serious problem trying to set up SSL on Tomcat 3.3.1 on
Windows 2000. I am following the jakarta guidelines exactly as they
propose, but I am having absolutely no luck. What am I doing wrong?
Here is the procedure I follow:
First, I run the following command -
keytool -genkey -keyalg rsa -alias name -keystore name
- I then answer the questions. I tried setting the common name as
my name, and a second time as the the URL used to access the site in
question, ie: sitename.com
Then, I issue the following command -
keytool -certreq -keystore name -alias name -file name.csr
Next, I send the name.csr file to the CA, and recieve 3 certificates.
The 3 certificates I receive are RootCert.cer, IntCert.cer and
NewCert.cer. So, I then issue the following commands in this order:
keytool -import -trustcacerts -file RootCert.cer -alias rootcert
-keystore name
keytool -import -trustcacerts -file IntCert.cer -alias intcert
-keystore name
keytool -import -trustcacerts -file NewCert.cer -alias newcert
-keystore name
After each command I receive confirmation that the certification was
properly inserted. I then copy the 'name' file to TOMCAT_HOME/conf
and edit the server.xml file. I add the following lines to the
server.xml file:
<Http10Connector
port="8443"
secure="true"
keystore="c:\tomcat\conf\name"
keypass="password"
clientauth="false"/>
Now, I restart tomcat and assume that everything should be in order.
When starting tomcat via the batch file, I see that an Http10Connector
is correctly sitting on port 8443. So, I try accessing the site
normally, and everything works fine. However, if I attempt an HTTPS
request to the site, I receive a page cannot be displayed error. This
is strange, because I figured that at this point it should work.
Well, I then attempted to access it manually by addressing
localhost:8443 .... this is where I noticed a problem. Once the
request is sent to Tomcat, Tomcat throws the following exception:
PoolTcpEndpoint: Handshake failed
javax.net.ssl.SSLException: Unrecognized SSL handshake.
at com.sun.net.ssl.internal.ssl.InputRecord.read(DashoA6275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(DashoA6275)
at java.io.OutputStream.write(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA6275)
at org.apache.tomcat.util.net.JSSESocketFactory.handshake(JSSESocketFactory.java:270)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:479)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Unknown Source)
ThreadPool: Caught exception executing
org.apache.tomcat.util.net.TcpWorkerThread@3a8602, terminating thread
java.lang.NullPointerException
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:498)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Unknown Source)
What is going on? Luckily, I have access to a CA, so this process
isn't costing me anything, however I have attempted this multiple
times with various certificates and various settings on the
certificate and I always get this same exception. What's more, I
tried creating a self signed certificate and I still get this
exception. Am I doing something wrong? I have scoured the net
countless times and it seems like all the instructions say the same
thing. When I search for this error, none of the recomendations fit
my situation. If no one knows how to fix this, could someone please
recomend where I can go so that I can find the answer to this problem?
Please help me out, this is driving me nuts. Thanks in advance,
Dan
- 6
- The simplest way to show a large output string?Hi,
What I want to do is quite simple: I want to show a large output String.
The user then will press "OK"; then the output window disappears, and
the program continues.
The following code would be ok for me, but the real String I want to
show is very long (let's say 1000 characters and 100 lines), so I need
scrollbars...
Could you please tell me the simplest way to achieve this? Thanks in
advance for your help.
==========================
package gui;
import javax.swing.*;
public class Prova {
public static void main(String[] args) {
String s = "hello";
JOptionPane.showMessageDialog(null, s);
System.exit(0);
}
}
=====================
- 6
- garbled JFrame
Ive got a a JFrame class displaying many JLabels with images inside.
It displays fine and I can drag it around the desktop ok.
But when I drag another window over the JFrame my JFrame gets garbled.(get
multiple images of the labels)
Even when i minimize it and maximize it is still garbled.
why would that be?
TIA
patrick
- 10
- UK Postcodes anyone know of a service ?Hi
My latest web application provides a search facility.
You sign up as a member and get a free entry in a searchable database.
I would like to offer a postcode search so that if someone is looking for a
particular service they can enter a postcode and return results within a number
of miles of the input postcode(s). I have seen this sort of search on a number
of sites to date and I was wondering if anyone knows of a web service or other
online service that will accept a post code (and some other params of course)
and return a list of postcodes within a parameters distance.
Once I have the list I can search my own database for results.
The service must be available over the network, I'm not intetested in static
databases that I have to install on the server (well I might be if they were
FREE :-).
Has anyone implemented such a thing ?
Does anyone know of such a service ?
Has this got anything to do with the group ? well I suppose not other than I
write in Java.
Cheers
anyway
Duncan
"Process- How will the work and the team be organized?
The team needs to fit the culture in which it will operate,
but you should write software well rather than preserve the
irrationality of an enclosing culture" - Kent Beck
- 12
- empty interfaces via reflectionOn Oct 14, 12:17 pm, "Aryeh M. Friedman" <email***@***.com>
wrote:
> On Oct 14, 6:01 pm, Steven Simpson <email***@***.com> wrote:
>
>
>
> > Aryeh M. Friedman wrote:
> > > Then how do you handle the return type?!?!?!? Namely I can't do:
>
> > > Class<?> testClass = loadTestClass();
> > > Object testInstance = testClass.newInstance();
> > > Result res=new Result();
>
> > > for (Method method: testClass.getDeclaredMethods())
> > > res.merge((Result) method.invoke(testInstance, new
> > > Object[0])); // cast exception
>
> > > The reason why it is not possible is any Result object created by a
> > > test is <MyClassLoader>.Result and all the results here are
> > > <SystemClassLoader>.Result
>
> > Looking back at an earlier post, your custom MyClassLoader goes like this:
>
> > > public class MyClassLoader extends ClassLoader
> > > {
> > > public Class loadClass(String name)
> > > {
> > > try {
> > > if(name.startsWith("java."))
> > > return super.loadClass(name);
>
> > A custom ClassLoader is expected to override findClass(String) rather
> > than loadClass(String), as the latter (indirectly) accomplishes this
> > behaviour:
>
> > <http://java.sun.com/javase/6/docs/api/java/lang/ClassLoader.html>
>
> > "When requested to find a class or resource, a ClassLoader instance will
> > delegate the search for the class or resource to its parent class loader
> > before attempting to find the class or resource itself."
>
> > MyClassLoader is loading Result instead of delegating to its parent
> > first, which should always find it first.
>
> I just tested:import java.io.*;
> import java.lang.reflect.*;
>
> public class MyClassLoader extends ClassLoader
> {
> public Class findClass(String name)
> {
> try {
> //if(name.startsWith("java."))
> // return super.loadClass(name);
>
> FileInputStream fis=new FileInputStream(name
> +".class");
> byte[] b=new byte[fis.available()];
>
> fis.read(b);
> fis.close();
>
> return defineClass(name,b,0,b.length);
> } catch(Throwable e) {
> e.printStackTrace();
> }
>
> return null;
>
> }
>
> and now the class loader no longer honors recompiled classes:
>
> Script started on Sun Oct 14 15:09:05 2007
> jtest@monster:/home/jtest% java Main
> 1
> ^Z
> Suspended
> jtest@monster:/home/jtest% cat foo
> import java.lang.reflect.*;
>
> public class MyClass
> {
> public MyClass()
> {
> ack=new Integer(2);
> }
>
> public Integer getAck()
> {
> return ack;
> }
>
> private int foo;
> private Integer ack;}
>
> jtest@monster:/home/jtest% cp foo MyClass.java
> jtest@monster:/home/jtest% javac MyClass.java
> jtest@monster:/home/jtest% fg
> java Main
>
> 1
> ^C
> jtest@monster:/home/jtest% exit
> Script ends on Sun Oct 14 15:09:45 2007
>
> Just for ref here is the new main():
>
> public class Main
> {
> public static void main(String[] args)
> throws Throwable
> {
> while(true) {
> ClassLoader loader=new MyClassLoader();
> Class klass=loader.loadClass("MyClass");
>
> MyClass m=(MyClass) klass.newInstance();
>
> System.out.println(m.getAck());
> System.in.read();
> }
> }
>
> }
You should simply use UrlClassLoader and have the system classpath not
include your code that needs to be reloaded, and the URLClassLoader
have the path that DOES need to be reloaded (creating a new instance
of that class loader every time you need to reload the class)
That way, Result will be properly loaded by the System class loader,
and your reloadable class wont.
Hoep this helps,
Daniel.
- 14
- Getting JAVA_HOME at runtimeHello,
The Java ports infrastructure provides JAVA_HOME on build-time to
port's Makefile. But is it possible to get this variable from
/usr/local/bin/java at runtime?
How to change the Java version for a port at runtime in the rc
script? It is possible to set the preferred JDK in
/usr/local/etc/javavms but then JAVA_HOME still needs to be
set manually.
I would like to avoid hard-coding the JAVA_HOME at build time in
the rc scripts.
Any idea?
--
Jean-Baptiste Quenot
aka John Banana Qwerty
http://caraldi.com/jbq/
- 14
- JAXB XML Max SizHello All:
I am using JAXB to reading (unmarshall) a XML feed which
is about 4GB of siz. The JAXB seems
can not doing its job. Any one knows how to solve this problem?
ps: does JAXB has a limitation over XML feed size?
Many Thanks!
- 15
- JSplitPane/JScrollPane Problem?Hey,
I'm writing an interface that has a verticle split pane, the top
and bottom of which both contain JScrollPanes with JEditor panes inside
each scrollpane. It sits within a JTabbedPane which is in a
JInternalFrame on a JDesktopPane.
JDesktopPane --> JTabbedPane --> Tab --> JSplitPane --> 2 ScrollPanes
--> 2 JEditorPanes.
The first EditorPane is a source area and the second is an error
output area. It's been working fine for me, which makes my current
dilema even worse.
I need to do the same format of error for an output tab so that
the output area is on top and the error output is on bottom. I took
the code from the previous working implementation and ported it and for
some reason it didn't work. The top component JScrollPane-->
JEditorPane does not show, but the bottom one does. Also, if I just
add the JScrollPane instead of the JSplitPane to the tab, it still
doesn't show, leading me to believe that it is a problem with the
implementation of the JScrollPane. Here are the code snippets of the
working and non-working portions of my code.
-----Working-----
source = new JEditorPane();
sourceError = new JEditorPane();
sourceError.setEditable(false);
JScrollPane scrollPane = new JScrollPane(source,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
JScrollPane errorScrollPane = new
JScrollPane(sourceError);
errorScrollPane.setBorder(BorderFactory.createEmptyBorder());
sourceSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
scrollPane,
errorScrollPane);
sourceSplit.setBorder(BorderFactory.createEmptyBorder());
-----Not Working-----
expressionOut = new JEditorPane();
outputError = new JEditorPane();
expressionOut.setEditable(false);
outputError.setEditable(false);
JScrollPane outputScroller = new
JScrollPane(expressionOut,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
outputScroller.setBorder(BorderFactory.createEmptyBorder());
JScrollPane outErrorScroller = new
JScrollPane(outputError);
outErrorScroller.setBorder(BorderFactory.createEmptyBorder());
sourceSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
outputScroller, outErrorScroller);
outputSplit.setBorder(BorderFactory.createEmptyBorder());
-----How They Are Added-----
tabFrame.addTab("Source", sourceSplit);
tabFrame.addTab("Output", outputSplit);
---------------
Any Ideas on why it isn't showing expressionOut?
- 16
- importing classs without package in JSP ?Hi,
i am working on apache server web based project and i want to import a
class without package in my JSP file.
All my classes are in "WEB-INF/classes"
if i use a package (such as "project") in a class (such as "match" )
then i can import class "match" in jsp using
<%@ page import="
java.util.*,
project.*
"%>
But if i dont have package then i dont know how to import my class in
JSP. Thats what i want to know .
PLease help me. i am really thankful to you guys.
Sincerely,
Jeff
- 16
- Please help..nu bee correct probable path.. (?)
ahmed khalak wrote:
> Hi
> Thank in advance.... I am getting error when I run from prompt (cmd)..
> I installed Jdk1.5.0_09 path is C:\Program files\Java\Jdk1.......
> I have oracle 9i and oracle 10g installed...
> Path and classpath I have put correctly in windowxp.. as follow
> path=C:\oracle..etc ;C:\Program File\java\Jdk1.5.0_09\bin
> classpath= .;C:\Program File\java\Jdk1.5.0_09\lib\root.jar
> Now when I check version for java and javac.. in other then Jdk1 directory
> I am getting version 1.3.1 where as jdk gives me it version I checked oracle
> directories
> In Oracle directory.. jre show 1.3.1 directory...
> how can I correct this problem.. my simple program compiles but running from
> promp gives error..
>
> would highly appreciate help
> :-) just starting learning Java..
>
> A Khalak
Change the path setting so it reads:
PATH=C:\Program File\java\Jdk1.5.0_09\bin;C:\oracle;...
The OS looks for commands on the PATH from left to right, so starting
with java, then oracle, and so on.
Besides this. The classpath setting isn't really needed. This is a
general note which might bring in problems later. If you don't have a
real need for it, simply remove the classpath setting. You can still
pass it to the java command using the "-classpath" switch.
Regards,
Bart
|
| Author |
Message |
Aaron Fude

|
Posted: 2004-12-18 5:16:00 |
Top |
java-programmer, An efficient computation idea. Please comment
Hi,
In my program I evaluate long trigonometric polynomials a lot! For example,
final int N = 1000;
double[] c = new double[N];
// Populate c
double x = .5, sum = 0.0;
for (int i = 0; i < N; i++)
sum += c[i]*cos(i*x);
And this function is evaluated very many times (about 100,000). So why not
create a java snippet, compile it, load it as a class and use the compiled
version. So I would have something like;
String sum = "0"; // A String buffer, of course...
for (int i = 0; i < N; i++)
sum += "+" + c[i] + "*cos(" + i + "*x)";
sum += ";";
I think it's a pretty cool idea. But before I implement it, I would like to
know what you think about it!
Thank you in advance!
Aaron Fude
|
| |
|
| |
 |
Patrick May

|
Posted: 2004-12-18 5:24:00 |
Top |
java-programmer >> An efficient computation idea. Please comment
"Aaron Fude" <email***@***.com> writes:
> In my program I evaluate long trigonometric polynomials a lot! For example,
>
> final int N = 1000;
> double[] c = new double[N];
> // Populate c
> double x = .5, sum = 0.0;
>
> for (int i = 0; i < N; i++)
> sum += c[i]*cos(i*x);
>
> And this function is evaluated very many times (about 100,000). So
> why not create a java snippet, compile it, load it as a class and
> use the compiled version. So I would have something like;
>
> String sum = "0"; // A String buffer, of course...
> for (int i = 0; i < N; i++)
> sum += "+" + c[i] + "*cos(" + i + "*x)";
> sum += ";";
>
> I think it's a pretty cool idea. But before I implement it, I would
> like to know what you think about it!
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an
ad-hoc, informally-specified, bug-ridden, slow implementation of
half of Common Lisp."
You have added Fude's Lemma: "Java programs, too."
Look up defmacro in the Common Lisp Hyperspec
(http://www.lispworks.com/reference/HyperSpec, among others). Java
doesn't allow you to do this particularly well. Lisp does.
Regards,
Patrick
------------------------------------------------------------------------
S P Engineering, Inc. | The experts in large scale distributed OO
| systems design and implementation.
email***@***.com | (C++, Java, ObjectStore, Oracle, CORBA, UML)
|
| |
|
| |
 |
Aaron Fude

|
Posted: 2004-12-18 5:47:00 |
Top |
java-programmer >> An efficient computation idea. Please comment
"Patrick May" <email***@***.com> wrote in message
news:email***@***.com...
> "Aaron Fude" <email***@***.com> writes:
>> In my program I evaluate long trigonometric polynomials a lot! For
>> example,
>>
>> final int N = 1000;
>> double[] c = new double[N];
>> // Populate c
>> double x = .5, sum = 0.0;
>>
>> for (int i = 0; i < N; i++)
>> sum += c[i]*cos(i*x);
>>
>> And this function is evaluated very many times (about 100,000). So
>> why not create a java snippet, compile it, load it as a class and
>> use the compiled version. So I would have something like;
>>
>> String sum = "0"; // A String buffer, of course...
>> for (int i = 0; i < N; i++)
>> sum += "+" + c[i] + "*cos(" + i + "*x)";
>> sum += ";";
>>
>> I think it's a pretty cool idea. But before I implement it, I would
>> like to know what you think about it!
>
> Greenspun's Tenth Rule of Programming:
> "Any sufficiently complicated C or Fortran program contains an
> ad-hoc, informally-specified, bug-ridden, slow implementation of
> half of Common Lisp."
>
> You have added Fude's Lemma: "Java programs, too."
>
> Look up defmacro in the Common Lisp Hyperspec
> (http://www.lispworks.com/reference/HyperSpec, among others). Java
> doesn't allow you to do this particularly well. Lisp does.
>
> Regards,
>
> Patrick
Hi Patrck,
I myself love Scheme and agree with that quote which I heard as "Inside
every C program there's a Lisp yearning to get out."
I expect that Java won't do this well. Nevertheless, will this be worth my
effort?
Thanks.
Aaron
|
| |
|
| |
 |
Mark Thornton

|
Posted: 2004-12-18 6:03:00 |
Top |
java-programmer >> An efficient computation idea. Please comment
Aaron Fude wrote:
> Hi,
>
> In my program I evaluate long trigonometric polynomials a lot! For example,
>
> final int N = 1000;
> double[] c = new double[N];
> // Populate c
> double x = .5, sum = 0.0;
>
> for (int i = 0; i < N; i++)
> sum += c[i]*cos(i*x);
>
> And this function is evaluated very many times (about 100,000). So why not
> create a java snippet, compile it, load it as a class and use the compiled
> version. So I would have something like;
A far better scheme would be to mathematically transform the calculation
to something which can be evaluated more cheaply. For example suppose we
calculate t = cos(x)
cos(0*x) = 1
cos(2*x) = 2*t*t-1
cos(3*x) = -3*t+4*t*t*t
etc
So we need only compute cos(x) (and perhaps sin(x)) and then find the
result with a series of much simpler operations (multiplication and
addition).
There are a number of different transformations which might be employed,
depending on the range of values expected for x and other
considerations. This approach can yield much more efficient evaluation
than the technique you suggest.
You might also want to review the literature on Fourier series.
Mark Thornton
|
| |
|
| |
 |
Mark Thornton

|
Posted: 2004-12-18 6:06:00 |
Top |
java-programmer >> An efficient computation idea. Please comment
Patrick May wrote:
> "Aaron Fude" <email***@***.com> writes:
>
>>In my program I evaluate long trigonometric polynomials a lot! For example,
>>
>>final int N = 1000;
>>double[] c = new double[N];
>>// Populate c
>>double x = .5, sum = 0.0;
>>
>>for (int i = 0; i < N; i++)
>> sum += c[i]*cos(i*x);
>>
>>And this function is evaluated very many times (about 100,000). So
>>why not create a java snippet, compile it, load it as a class and
>>use the compiled version. So I would have something like;
>>
>>String sum = "0"; // A String buffer, of course...
>>for (int i = 0; i < N; i++)
>> sum += "+" + c[i] + "*cos(" + i + "*x)";
>>sum += ";";
>>
>>I think it's a pretty cool idea. But before I implement it, I would
>>like to know what you think about it!
>
>
> Greenspun's Tenth Rule of Programming:
> "Any sufficiently complicated C or Fortran program contains an
> ad-hoc, informally-specified, bug-ridden, slow implementation of
> half of Common Lisp."
>
> You have added Fude's Lemma: "Java programs, too."
>
> Look up defmacro in the Common Lisp Hyperspec
> (http://www.lispworks.com/reference/HyperSpec, among others). Java
> doesn't allow you to do this particularly well. Lisp does.
>
However in this particular case there is a much better way of evaluating
the required function. A good understanding of mathematics is what is
required.
Mark Thornton
|
| |
|
| |
 |
Aaron Fude

|
Posted: 2004-12-18 6:33:00 |
Top |
java-programmer >> An efficient computation idea. Please comment
"Mark Thornton" <email***@***.com> wrote in message
news:email***@***.com...
> Patrick May wrote:
>> "Aaron Fude" <email***@***.com> writes:
>>
>>>In my program I evaluate long trigonometric polynomials a lot! For
>>>example,
>>>
>>>final int N = 1000;
>>>double[] c = new double[N];
>>>// Populate c
>>>double x = .5, sum = 0.0;
>>>
>>>for (int i = 0; i < N; i++)
>>> sum += c[i]*cos(i*x);
>>>
>>>And this function is evaluated very many times (about 100,000). So
>>>why not create a java snippet, compile it, load it as a class and
>>>use the compiled version. So I would have something like;
>>>
>>>String sum = "0"; // A String buffer, of course...
>>>for (int i = 0; i < N; i++)
>>> sum += "+" + c[i] + "*cos(" + i + "*x)";
>>>sum += ";";
>>>
>>>I think it's a pretty cool idea. But before I implement it, I would
>>>like to know what you think about it!
>>
>>
>> Greenspun's Tenth Rule of Programming:
>> "Any sufficiently complicated C or Fortran program contains an
>> ad-hoc, informally-specified, bug-ridden, slow implementation of
>> half of Common Lisp."
>>
>> You have added Fude's Lemma: "Java programs, too."
>>
>> Look up defmacro in the Common Lisp Hyperspec
>> (http://www.lispworks.com/reference/HyperSpec, among others). Java
>> doesn't allow you to do this particularly well. Lisp does.
>>
>
> However in this particular case there is a much better way of evaluating
> the required function. A good understanding of mathematics is what is
> required.
>
> Mark Thornton
Your comment about unwrapping cosines is undoubtedly correct. To tell you
the truth, I don't even have cosines, I have elementary polynomials. I have
contrived the cosine example so I wouldn't get responses about summing the
series in inverse order - and it backfired. (BTW, how many flops does a
cosine take? I have no idea, but I would guess about 50. Wouldn't that mean
that by the time you get to cos(50*x) it's cheaper to evaluate the cosine?)
In any case, now that we know that I have polynomial, perhaps you could
answer the posed question in the context of polynomials. Is there added
value to the compilation trick if my series has about 1000 terms and needs
to be evaluated 100k times?
Aaron Fude
|
| |
|
| |
 |
Mark Thornton

|
Posted: 2004-12-18 7:02:00 |
Top |
java-programmer >> An efficient computation idea. Please comment
Aaron Fude wrote:
> "Mark Thornton" <email***@***.com> wrote in message
> news:email***@***.com...
>
>>Patrick May wrote:
>>
>>>"Aaron Fude" <email***@***.com> writes:
>>>
>>>
>>>>In my program I evaluate long trigonometric polynomials a lot! For
>>>>example,
>>>>
>>>>final int N = 1000;
>>>>double[] c = new double[N];
>>>>// Populate c
>>>>double x = .5, sum = 0.0;
>>>>
>>>>for (int i = 0; i < N; i++)
>>>> sum += c[i]*cos(i*x);
>>>>
>>>>And this function is evaluated very many times (about 100,000). So
>>>>why not create a java snippet, compile it, load it as a class and
>>>>use the compiled version. So I would have something like;
>>>>
>>>>String sum = "0"; // A String buffer, of course...
>>>>for (int i = 0; i < N; i++)
>>>> sum += "+" + c[i] + "*cos(" + i + "*x)";
>>>>sum += ";";
>>>>
>>>>I think it's a pretty cool idea. But before I implement it, I would
>>>>like to know what you think about it!
>>>
>>>
>>>Greenspun's Tenth Rule of Programming:
>>> "Any sufficiently complicated C or Fortran program contains an
>>> ad-hoc, informally-specified, bug-ridden, slow implementation of
>>> half of Common Lisp."
>>>
>>>You have added Fude's Lemma: "Java programs, too."
>>>
>>>Look up defmacro in the Common Lisp Hyperspec
>>>(http://www.lispworks.com/reference/HyperSpec, among others). Java
>>>doesn't allow you to do this particularly well. Lisp does.
>>>
>>
>>However in this particular case there is a much better way of evaluating
>>the required function. A good understanding of mathematics is what is
>>required.
>>
>>Mark Thornton
>
>
> Your comment about unwrapping cosines is undoubtedly correct. To tell you
> the truth, I don't even have cosines, I have elementary polynomials. I have
> contrived the cosine example so I wouldn't get responses about summing the
> series in inverse order - and it backfired. (BTW, how many flops does a
> cosine take? I have no idea, but I would guess about 50. Wouldn't that mean
> that by the time you get to cos(50*x) it's cheaper to evaluate the cosine?)
No, because in practice a recurrence relation is used to compute each
successive term from previous values. Just as with evaluating
polynomials you don't compute x^n from scratch at each term. It is in
fact very similar as exp(iz) = cos(z) + i.sin(z) (where 'i' here is the
sqrt of -1). Now note that exp(i.n.z) = exp(iz)^n
> In any case, now that we know that I have polynomial, perhaps you could
> answer the posed question in the context of polynomials. Is there added
> value to the compilation trick if my series has about 1000 terms and needs
> to be evaluated 100k times?
It still isn't worth generating byte code. Many JIT compilers will have
been tuned to recognise this type of loop and may do some unrolling
themselves.
More seriously you need to consider the numerical stability of a power
series with 1000 terms. There are a number of methods to 'improve' such
series, which would then usually leave you with a much smaller
polynomial to evaluate. However this a complex subject which filled many
lectures during my maths degree (25 years ago).
I suggest you find a mathematician to help economise the series, and
evaluate it in the straight forward manner.
Mark Thornton
|
| |
|
| |
 |
Aaron Fude

|
Posted: 2004-12-18 11:29:00 |
Top |
java-programmer >> An efficient computation idea. Please comment
Mark,
Here's some funny code for you which shows that compiled code may run faster
(typically by a factor of 3 on my machine).
In really, the effect will be even greater for me since the series would
have coefficients that come from some kind of a list with potentially
significant access time. Now, as you wisely noted, .999^555 is quickly
computed as .999^554*.999. That's very true, but perhaps it won't change the
fact that the compilation trick on top of your keen observation is a good
idea.
Aaron
public static void main(String[] inStr) {
int N = 0;
int M = 0;
try {
N = Math.max(1000, System.in.read()); // To prevent simple
unwrapping...
M = Math.max(100, System.in.read());
}
catch (Exception inE) { }
{
long start = System.currentTimeMillis();
double sum = 0;
for (int m = 0; m < M; m++)
for (int n = 0; n < N; n++)
sum += Math.pow(.999, n);
System.out.println(System.currentTimeMillis() - start);
}
{
long start = System.currentTimeMillis();
double sum = 0;
for (int m = 0; m < M; m++)
sum = 0 + Math.pow(.999, 0) + Math.pow(.999, 1) + Math.pow(.999,
2) + Math.pow(.999, 3) + Math.pow(.999, 4) + Math.pow(.999, 5) +
Math.pow(.999, 6) + Math.pow(.999, 7) + Math.pow(.999, 8) +
Math.pow(.999, 9) + Math.pow(.999, 10) + Math.pow(.999, 11) +
Math.pow(.999, 12) + Math.pow(.999, 13) + Math.pow(.999, 14) +
Math.pow(.999, 15) + Math.pow(.999, 16) + Math.pow(.999, 17) +
Math.pow(.999, 18) + Math.pow(.999, 19) + Math.pow(.999, 20) +
Math.pow(.999, 21) + Math.pow(.999, 22) + Math.pow(.999, 23) +
Math.pow(.999, 24) + Math.pow(.999, 25) + Math.pow(.999, 26) +
Math.pow(.999, 27) + Math.pow(.999, 28) + Math.pow(.999, 29) +
Math.pow(.999, 30) + Math.pow(.999, 31) + Math.pow(.999, 32) +
Math.pow(.999, 33) + Math.pow(.999, 34) + Math.pow(.999, 35) +
Math.pow(.999, 36) + Math.pow(.999, 37) + Math.pow(.999, 38) +
Math.pow(.999, 39) + Math.pow(.999, 40) + Math.pow(.999, 41) +
Math.pow(.999, 42) + Math.pow(.999, 43) + Math.pow(.999, 44) +
Math.pow(.999, 45) + Math.pow(.999, 46) + Math.pow(.999, 47) +
Math.pow(.999, 48) + Math.pow(.999, 49) + Math.pow(.999, 50) +
Math.pow(.999, 51) + Math.pow(.999, 52) + Math.pow(.999, 53) +
Math.pow(.999, 54) + Math.pow(.999, 55) + Math.pow(.999, 56) +
Math.pow(.999, 57) + Math.pow(.999, 58) + Math.pow(.999, 59) +
Math.pow(.999, 60) + Math.pow(.999, 61) + Math.pow(.999, 62) +
Math.pow(.999, 63) + Math.pow(.999, 64) + Math.pow(.999, 65) +
Math.pow(.999, 66) + Math.pow(.999, 67) + Math.pow(.999, 68) +
Math.pow(.999, 69) + Math.pow(.999, 70) + Math.pow(.999, 71) +
Math.pow(.999, 72) + Math.pow(.999, 73) + Math.pow(.999, 74) +
Math.pow(.999, 75) + Math.pow(.999, 76) + Math.pow(.999, 77) +
Math.pow(.999, 78) + Math.pow(.999, 79) + Math.pow(.999, 80) +
Math.pow(.999, 81) + Math.pow(.999, 82) + Math.pow(.999, 83) +
Math.pow(.999, 84) + Math.pow(.999, 85) + Math.pow(.999, 86) +
Math.pow(.999, 87) + Math.pow(.999, 88) + Math.pow(.999, 89) +
Math.pow(.999, 90) + Math.pow(.999, 91) + Math.pow(.999, 92) +
Math.pow(.999, 93) + Math.pow(.999, 94) + Math.pow(.999, 95) +
Math.pow(.999, 96) + Math.pow(.999, 97) + Math.pow(.999, 98) +
Math.pow(.999, 99) + Math.pow(.999, 100) + Math.pow(.999, 101) +
Math.pow(.999, 102) + Math.pow(.999, 103) + Math.pow(.999, 104) +
Math.pow(.999, 105) + Math.pow(.999, 106) + Math.pow(.999, 107) +
Math.pow(.999, 108) + Math.pow(.999, 109) + Math.pow(.999, 110) +
Math.pow(.999, 111) + Math.pow(.999, 112) + Math.pow(.999, 113) +
Math.pow(.999, 114) + Math.pow(.999, 115) + Math.pow(.999, 116) +
Math.pow(.999, 117) + Math.pow(.999, 118) + Math.pow(.999, 119) +
Math.pow(.999, 120) + Math.pow(.999, 121) + Math.pow(.999, 122) +
Math.pow(.999, 123) + Math.pow(.999, 124) + Math.pow(.999, 125) +
Math.pow(.999, 126) + Math.pow(.999, 127) + Math.pow(.999, 128) +
Math.pow(.999, 129) + Math.pow(.999, 130) + Math.pow(.999, 131) +
Math.pow(.999, 132) + Math.pow(.999, 133) + Math.pow(.999, 134) +
Math.pow(.999, 135) + Math.pow(.999, 136) + Math.pow(.999, 137) +
Math.pow(.999, 138) + Math.pow(.999, 139) + Math.pow(.999, 140) +
Math.pow(.999, 141) + Math.pow(.999, 142) + Math.pow(.999, 143) +
Math.pow(.999, 144) + Math.pow(.999, 145) + Math.pow(.999, 146) +
Math.pow(.999, 147) + Math.pow(.999, 148) + Math.pow(.999, 149) +
Math.pow(.999, 150) + Math.pow(.999, 151) + Math.pow(.999, 152) +
Math.pow(.999, 153) + Math.pow(.999, 154) + Math.pow(.999, 155) +
Math.pow(.999, 156) + Math.pow(.999, 157) + Math.pow(.999, 158) +
Math.pow(.999, 159) + Math.pow(.999, 160) + Math.pow(.999, 161) +
Math.pow(.999, 162) + Math.pow(.999, 163) + Math.pow(.999, 164) +
Math.pow(.999, 165) + Math.pow(.999, 166) + Math.pow(.999, 167) +
Math.pow(.999, 168) + Math.pow(.999, 169) + Math.pow(.999, 170) +
Math.pow(.999, 171) + Math.pow(.999, 172) + Math.pow(.999, 173) +
Math.pow(.999, 174) + Math.pow(.999, 175) + Math.pow(.999, 176) +
Math.pow(.999, 177) + Math.pow(.999, 178) + Math.pow(.999, 179) +
Math.pow(.999, 180) + Math.pow(.999, 181) + Math.pow(.999, 182) +
Math.pow(.999, 183) + Math.pow(.999, 184) + Math.pow(.999, 185) +
Math.pow(.999, 186) + Math.pow(.999, 187) + Math.pow(.999, 188) +
Math.pow(.999, 189) + Math.pow(.999, 190) + Math.pow(.999, 191) +
Math.pow(.999, 192) + Math.pow(.999, 193) + Math.pow(.999, 194) +
Math.pow(.999, 195) + Math.pow(.999, 196) + Math.pow(.999, 197) +
Math.pow(.999, 198) + Math.pow(.999, 199) + Math.pow(.999, 200) +
Math.pow(.999, 201) + Math.pow(.999, 202) + Math.pow(.999, 203) +
Math.pow(.999, 204) + Math.pow(.999, 205) + Math.pow(.999, 206) +
Math.pow(.999, 207) + Math.pow(.999, 208) + Math.pow(.999, 209) +
Math.pow(.999, 210) + Math.pow(.999, 211) + Math.pow(.999, 212) +
Math.pow(.999, 213) + Math.pow(.999, 214) + Math.pow(.999, 215) +
Math.pow(.999, 216) + Math.pow(.999, 217) + Math.pow(.999, 218) +
Math.pow(.999, 219) + Math.pow(.999, 220) + Math.pow(.999, 221) +
Math.pow(.999, 222) + Math.pow(.999, 223) + Math.pow(.999, 224) +
Math.pow(.999, 225) + Math.pow(.999, 226) + Math.pow(.999, 227) +
Math.pow(.999, 228) + Math.pow(.999, 229) + Math.pow(.999, 230) +
Math.pow(.999, 231) + Math.pow(.999, 232) + Math.pow(.999, 233) +
Math.pow(.999, 234) + Math.pow(.999, 235) + Math.pow(.999, 236) +
Math.pow(.999, 237) + Math.pow(.999, 238) + Math.pow(.999, 239) +
Math.pow(.999, 240) + Math.pow(.999, 241) + Math.pow(.999, 242) +
Math.pow(.999, 243) + Math.pow(.999, 244) + Math.pow(.999, 245) +
Math.pow(.999, 246) + Math.pow(.999, 247) + Math.pow(.999, 248) +
Math.pow(.999, 249) + Math.pow(.999, 250) + Math.pow(.999, 251) +
Math.pow(.999, 252) + Math.pow(.999, 253) + Math.pow(.999, 254) +
Math.pow(.999, 255) + Math.pow(.999, 256) + Math.pow(.999, 257) +
Math.pow(.999, 258) + Math.pow(.999, 259) + Math.pow(.999, 260) +
Math.pow(.999, 261) + Math.pow(.999, 262) + Math.pow(.999, 263) +
Math.pow(.999, 264) + Math.pow(.999, 265) + Math.pow(.999, 266) +
Math.pow(.999, 267) + Math.pow(.999, 268) + Math.pow(.999, 269) +
Math.pow(.999, 270) + Math.pow(.999, 271) + Math.pow(.999, 272) +
Math.pow(.999, 273) + Math.pow(.999, 274) + Math.pow(.999, 275) +
Math.pow(.999, 276) + Math.pow(.999, 277) + Math.pow(.999, 278) +
Math.pow(.999, 279) + Math.pow(.999, 280) + Math.pow(.999, 281) +
Math.pow(.999, 282) + Math.pow(.999, 283) + Math.pow(.999, 284) +
Math.pow(.999, 285) + Math.pow(.999, 286) + Math.pow(.999, 287) +
Math.pow(.999, 288) + Math.pow(.999, 289) + Math.pow(.999, 290) +
Math.pow(.999, 291) + Math.pow(.999, 292) + Math.pow(.999, 293) +
Math.pow(.999, 294) + Math.pow(.999, 295) + Math.pow(.999, 296) +
Math.pow(.999, 297) + Math.pow(.999, 298) + Math.pow(.999, 299) +
Math.pow(.999, 300) + Math.pow(.999, 301) + Math.pow(.999, 302) +
Math.pow(.999, 303) + Math.pow(.999, 304) + Math.pow(.999, 305) +
Math.pow(.999, 306) + Math.pow(.999, 307) + Math.pow(.999, 308) +
Math.pow(.999, 309) + Math.pow(.999, 310) + Math.pow(.999, 311) +
Math.pow(.999, 312) + Math.pow(.999, 313) + Math.pow(.999, 314) +
Math.pow(.999, 315) + Math.pow(.999, 316) + Math.pow(.999, 317) +
Math.pow(.999, 318) + Math.pow(.999, 319) + Math.pow(.999, 320) +
Math.pow(.999, 321) + Math.pow(.999, 322) + Math.pow(.999, 323) +
Math.pow(.999, 324) + Math.pow(.999, 325) + Math.pow(.999, 326) +
Math.pow(.999, 327) + Math.pow(.999, 328) + Math.pow(.999, 329) +
Math.pow(.999, 330) + Math.pow(.999, 331) + Math.pow(.999, 332) +
Math.pow(.999, 333) + Math.pow(.999, 334) + Math.pow(.999, 335) +
Math.pow(.999, 336) + Math.pow(.999, 337) + Math.pow(.999, 338) +
Math.pow(.999, 339) + Math.pow(.999, 340) + Math.pow(.999, 341) +
Math.pow(.999, 342) + Math.pow(.999, 343) + Math.pow(.999, 344) +
Math.pow(.999, 345) + Math.pow(.999, 346) + Math.pow(.999, 347) +
Math.pow(.999, 348) + Math.pow(.999, 349) + Math.pow(.999, 350) +
Math.pow(.999, 351) + Math.pow(.999, 352) + Math.pow(.999, 353) +
Math.pow(.999, 354) + Math.pow(.999, 355) + Math.pow(.999, 356) +
Math.pow(.999, 357) + Math.pow(.999, 358) + Math.pow(.999, 359) +
Math.pow(.999, 360) + Math.pow(.999, 361) + Math.pow(.999, 362) +
Math.pow(.999, 363) + Math.pow(.999, 364) + Math.pow(.999, 365) +
Math.pow(.999, 366) + Math.pow(.999, 367) + Math.pow(.999, 368) +
Math.pow(.999, 369) + Math.pow(.999, 370) + Math.pow(.999, 371) +
Math.pow(.999, 372) + Math.pow(.999, 373) + Math.pow(.999, 374) +
Math.pow(.999, 375) + Math.pow(.999, 376) + Math.pow(.999, 377) +
Math.pow(.999, 378) + Math.pow(.999, 379) + Math.pow(.999, 380) +
Math.pow(.999, 381) + Math.pow(.999, 382) + Math.pow(.999, 383) +
Math.pow(.999, 384) + Math.pow(.999, 385) + Math.pow(.999, 386) +
Math.pow(.999, 387) + Math.pow(.999, 388) + Math.pow(.999, 389) +
Math.pow(.999, 390) + Math.pow(.999, 391) + Math.pow(.999, 392) +
Math.pow(.999, 393) + Math.pow(.999, 394) + Math.pow(.999, 395) +
Math.pow(.999, 396) + Math.pow(.999, 397) + Math.pow(.999, 398) +
Math.pow(.999, 399) + Math.pow(.999, 400) + Math.pow(.999, 401) +
Math.pow(.999, 402) + Math.pow(.999, 403) + Math.pow(.999, 404) +
Math.pow(.999, 405) + Math.pow(.999, 406) + Math.pow(.999, 407) +
Math.pow(.999, 408) + Math.pow(.999, 409) + Math.pow(.999, 410) +
Math.pow(.999, 411) + Math.pow(.999, 412) + Math.pow(.999, 413) +
Math.pow(.999, 414) + Math.pow(.999, 415) + Math.pow(.999, 416) +
Math.pow(.999, 417) + Math.pow(.999, 418) + Math.pow(.999, 419) +
Math.pow(.999, 420) + Math.pow(.999, 421) + Math.pow(.999, 422) +
Math.pow(.999, 423) + Math.pow(.999, 424) + Math.pow(.999, 425) +
Math.pow(.999, 426) + Math.pow(.999, 427) + Math.pow(.999, 428) +
Math.pow(.999, 429) + Math.pow(.999, 430) + Math.pow(.999, 431) +
Math.pow(.999, 432) + Math.pow(.999, 433) + Math.pow(.999, 434) +
Math.pow(.999, 435) + Math.pow(.999, 436) + Math.pow(.999, 437) +
Math.pow(.999, 438) + Math.pow(.999, 439) + Math.pow(.999, 440) +
Math.pow(.999, 441) + Math.pow(.999, 442) + Math.pow(.999, 443) +
Math.pow(.999, 444) + Math.pow(.999, 445) + Math.pow(.999, 446) +
Math.pow(.999, 447) + Math.pow(.999, 448) + Math.pow(.999, 449) +
Math.pow(.999, 450) + Math.pow(.999, 451) + Math.pow(.999, 452) +
Math.pow(.999, 453) + Math.pow(.999, 454) + Math.pow(.999, 455) +
Math.pow(.999, 456) + Math.pow(.999, 457) + Math.pow(.999, 458) +
Math.pow(.999, 459) + Math.pow(.999, 460) + Math.pow(.999, 461) +
Math.pow(.999, 462) + Math.pow(.999, 463) + Math.pow(.999, 464) +
Math.pow(.999, 465) + Math.pow(.999, 466) + Math.pow(.999, 467) +
Math.pow(.999, 468) + Math.pow(.999, 469) + Math.pow(.999, 470) +
Math.pow(.999, 471) + Math.pow(.999, 472) + Math.pow(.999, 473) +
Math.pow(.999, 474) + Math.pow(.999, 475) + Math.pow(.999, 476) +
Math.pow(.999, 477) + Math.pow(.999, 478) + Math.pow(.999, 479) +
Math.pow(.999, 480) + Math.pow(.999, 481) + Math.pow(.999, 482) +
Math.pow(.999, 483) + Math.pow(.999, 484) + Math.pow(.999, 485) +
Math.pow(.999, 486) + Math.pow(.999, 487) + Math.pow(.999, 488) +
Math.pow(.999, 489) + Math.pow(.999, 490) + Math.pow(.999, 491) +
Math.pow(.999, 492) + Math.pow(.999, 493) + Math.pow(.999, 494) +
Math.pow(.999, 495) + Math.pow(.999, 496) + Math.pow(.999, 497) +
Math.pow(.999, 498) + Math.pow(.999, 499) + Math.pow(.999, 500) +
Math.pow(.999, 501) + Math.pow(.999, 502) + Math.pow(.999, 503) +
Math.pow(.999, 504) + Math.pow(.999, 505) + Math.pow(.999, 506) +
Math.pow(.999, 507) + Math.pow(.999, 508) + Math.pow(.999, 509) +
Math.pow(.999, 510) + Math.pow(.999, 511) + Math.pow(.999, 512) +
Math.pow(.999, 513) + Math.pow(.999, 514) + Math.pow(.999, 515) +
Math.pow(.999, 516) + Math.pow(.999, 517) + Math.pow(.999, 518) +
Math.pow(.999, 519) + Math.pow(.999, 520) + Math.pow(.999, 521) +
Math.pow(.999, 522) + Math.pow(.999, 523) + Math.pow(.999, 524) +
Math.pow(.999, 525) + Math.pow(.999, 526) + Math.pow(.999, 527) +
Math.pow(.999, 528) + Math.pow(.999, 529) + Math.pow(.999, 530) +
Math.pow(.999, 531) + Math.pow(.999, 532) + Math.pow(.999, 533) +
Math.pow(.999, 534) + Math.pow(.999, 535) + Math.pow(.999, 536) +
Math.pow(.999, 537) + Math.pow(.999, 538) + Math.pow(.999, 539) +
Math.pow(.999, 540) + Math.pow(.999, 541) + Math.pow(.999, 542) +
Math.pow(.999, 543) + Math.pow(.999, 544) + Math.pow(.999, 545) +
Math.pow(.999, 546) + Math.pow(.999, 547) + Math.pow(.999, 548) +
Math.pow(.999, 549) + Math.pow(.999, 550) + Math.pow(.999, 551) +
Math.pow(.999, 552) + Math.pow(.999, 553) + Math.pow(.999, 554) +
Math.pow(.999, 555) + Math.pow(.999, 556) + Math.pow(.999, 557) +
Math.pow(.999, 558) + Math.pow(.999, 559) + Math.pow(.999, 560) +
Math.pow(.999, 561) + Math.pow(.999, 562) + Math.pow(.999, 563) +
Math.pow(.999, 564) + Math.pow(.999, 565) + Math.pow(.999, 566) +
Math.pow(.999, 567) + Math.pow(.999, 568) + Math.pow(.999, 569) +
Math.pow(.999, 570) + Math.pow(.999, 571) + Math.pow(.999, 572) +
Math.pow(.999, 573) + Math.pow(.999, 574) + Math.pow(.999, 575) +
Math.pow(.999, 576) + Math.pow(.999, 577) + Math.pow(.999, 578) +
Math.pow(.999, 579) + Math.pow(.999, 580) + Math.pow(.999, 581) +
Math.pow(.999, 582) + Math.pow(.999, 583) + Math.pow(.999, 584) +
Math.pow(.999, 585) + Math.pow(.999, 586) + Math.pow(.999, 587) +
Math.pow(.999, 588) + Math.pow(.999, 589) + Math.pow(.999, 590) +
Math.pow(.999, 591) + Math.pow(.999, 592) + Math.pow(.999, 593) +
Math.pow(.999, 594) + Math.pow(.999, 595) + Math.pow(.999, 596) +
Math.pow(.999, 597) + Math.pow(.999, 598) + Math.pow(.999, 599) +
Math.pow(.999, 600) + Math.pow(.999, 601) + Math.pow(.999, 602) +
Math.pow(.999, 603) + Math.pow(.999, 604) + Math.pow(.999, 605) +
Math.pow(.999, 606) + Math.pow(.999, 607) + Math.pow(.999, 608) +
Math.pow(.999, 609) + Math.pow(.999, 610) + Math.pow(.999, 611) +
Math.pow(.999, 612) + Math.pow(.999, 613) + Math.pow(.999, 614) +
Math.pow(.999, 615) + Math.pow(.999, 616) + Math.pow(.999, 617) +
Math.pow(.999, 618) + Math.pow(.999, 619) + Math.pow(.999, 620) +
Math.pow(.999, 621) + Math.pow(.999, 622) + Math.pow(.999, 623) +
Math.pow(.999, 624) + Math.pow(.999, 625) + Math.pow(.999, 626) +
Math.pow(.999, 627) + Math.pow(.999, 628) + Math.pow(.999, 629) +
Math.pow(.999, 630) + Math.pow(.999, 631) + Math.pow(.999, 632) +
Math.pow(.999, 633) + Math.pow(.999, 634) + Math.pow(.999, 635) +
Math.pow(.999, 636) + Math.pow(.999, 637) + Math.pow(.999, 638) +
Math.pow(.999, 639) + Math.pow(.999, 640) + Math.pow(.999, 641) +
Math.pow(.999, 642) + Math.pow(.999, 643) + Math.pow(.999, 644) +
Math.pow(.999, 645) + Math.pow(.999, 646) + Math.pow(.999, 647) +
Math.pow(.999, 648) + Math.pow(.999, 649) + Math.pow(.999, 650) +
Math.pow(.999, 651) + Math.pow(.999, 652) + Math.pow(.999, 653) +
Math.pow(.999, 654) + Math.pow(.999, 655) + Math.pow(.999, 656) +
Math.pow(.999, 657) + Math.pow(.999, 658) + Math.pow(.999, 659) +
Math.pow(.999, 660) + Math.pow(.999, 661) + Math.pow(.999, 662) +
Math.pow(.999, 663) + Math.pow(.999, 664) + Math.pow(.999, 665) +
Math.pow(.999, 666) + Math.pow(.999, 667) + Math.pow(.999, 668) +
Math.pow(.999, 669) + Math.pow(.999, 670) + Math.pow(.999, 671) +
Math.pow(.999, 672) + Math.pow(.999, 673) + Math.pow(.999, 674) +
Math.pow(.999, 675) + Math.pow(.999, 676) + Math.pow(.999, 677) +
Math.pow(.999, 678) + Math.pow(.999, 679) + Math.pow(.999, 680) +
Math.pow(.999, 681) + Math.pow(.999, 682) + Math.pow(.999, 683) +
Math.pow(.999, 684) + Math.pow(.999, 685) + Math.pow(.999, 686) +
Math.pow(.999, 687) + Math.pow(.999, 688) + Math.pow(.999, 689) +
Math.pow(.999, 690) + Math.pow(.999, 691) + Math.pow(.999, 692) +
Math.pow(.999, 693) + Math.pow(.999, 694) + Math.pow(.999, 695) +
Math.pow(.999, 696) + Math.pow(.999, 697) + Math.pow(.999, 698) +
Math.pow(.999, 699) + Math.pow(.999, 700) + Math.pow(.999, 701) +
Math.pow(.999, 702) + Math.pow(.999, 703) + Math.pow(.999, 704) +
Math.pow(.999, 705) + Math.pow(.999, 706) + Math.pow(.999, 707) +
Math.pow(.999, 708) + Math.pow(.999, 709) + Math.pow(.999, 710) +
Math.pow(.999, 711) + Math.pow(.999, 712) + Math.pow(.999, 713) +
Math.pow(.999, 714) + Math.pow(.999, 715) + Math.pow(.999, 716) +
Math.pow(.999, 717) + Math.pow(.999, 718) + Math.pow(.999, 719) +
Math.pow(.999, 720) + Math.pow(.999, 721) + Math.pow(.999, 722) +
Math.pow(.999, 723) + Math.pow(.999, 724) + Math.pow(.999, 725) +
Math.pow(.999, 726) + Math.pow(.999, 727) + Math.pow(.999, 728) +
Math.pow(.999, 729) + Math.pow(.999, 730) + Math.pow(.999, 731) +
Math.pow(.999, 732) + Math.pow(.999, 733) + Math.pow(.999, 734) +
Math.pow(.999, 735) + Math.pow(.999, 736) + Math.pow(.999, 737) +
Math.pow(.999, 738) + Math.pow(.999, 739) + Math.pow(.999, 740) +
Math.pow(.999, 741) + Math.pow(.999, 742) + Math.pow(.999, 743) +
Math.pow(.999, 744) + Math.pow(.999, 745) + Math.pow(.999, 746) +
Math.pow(.999, 747) + Math.pow(.999, 748) + Math.pow(.999, 749) +
Math.pow(.999, 750) + Math.pow(.999, 751) + Math.pow(.999, 752) +
Math.pow(.999, 753) + Math.pow(.999, 754) + Math.pow(.999, 755) +
Math.pow(.999, 756) + Math.pow(.999, 757) + Math.pow(.999, 758) +
Math.pow(.999, 759) + Math.pow(.999, 760) + Math.pow(.999, 761) +
Math.pow(.999, 762) + Math.pow(.999, 763) + Math.pow(.999, 764) +
Math.pow(.999, 765) + Math.pow(.999, 766) + Math.pow(.999, 767) +
Math.pow(.999, 768) + Math.pow(.999, 769) + Math.pow(.999, 770) +
Math.pow(.999, 771) + Math.pow(.999, 772) + Math.pow(.999, 773) +
Math.pow(.999, 774) + Math.pow(.999, 775) + Math.pow(.999, 776) +
Math.pow(.999, 777) + Math.pow(.999, 778) + Math.pow(.999, 779) +
Math.pow(.999, 780) + Math.pow(.999, 781) + Math.pow(.999, 782) +
Math.pow(.999, 783) + Math.pow(.999, 784) + Math.pow(.999, 785) +
Math.pow(.999, 786) + Math.pow(.999, 787) + Math.pow(.999, 788) +
Math.pow(.999, 789) + Math.pow(.999, 790) + Math.pow(.999, 791) +
Math.pow(.999, 792) + Math.pow(.999, 793) + Math.pow(.999, 794) +
Math.pow(.999, 795) + Math.pow(.999, 796) + Math.pow(.999, 797) +
Math.pow(.999, 798) + Math.pow(.999, 799) + Math.pow(.999, 800) +
Math.pow(.999, 801) + Math.pow(.999, 802) + Math.pow(.999, 803) +
Math.pow(.999, 804) + Math.pow(.999, 805) + Math.pow(.999, 806) +
Math.pow(.999, 807) + Math.pow(.999, 808) + Math.pow(.999, 809) +
Math.pow(.999, 810) + Math.pow(.999, 811) + Math.pow(.999, 812) +
Math.pow(.999, 813) + Math.pow(.999, 814) + Math.pow(.999, 815) +
Math.pow(.999, 816) + Math.pow(.999, 817) + Math.pow(.999, 818) +
Math.pow(.999, 819) + Math.pow(.999, 820) + Math.pow(.999, 821) +
Math.pow(.999, 822) + Math.pow(.999, 823) + Math.pow(.999, 824) +
Math.pow(.999, 825) + Math.pow(.999, 826) + Math.pow(.999, 827) +
Math.pow(.999, 828) + Math.pow(.999, 829) + Math.pow(.999, 830) +
Math.pow(.999, 831) + Math.pow(.999, 832) + Math.pow(.999, 833) +
Math.pow(.999, 834) + Math.pow(.999, 835) + Math.pow(.999, 836) +
Math.pow(.999, 837) + Math.pow(.999, 838) + Math.pow(.999, 839) +
Math.pow(.999, 840) + Math.pow(.999, 841) + Math.pow(.999, 842) +
Math.pow(.999, 843) + Math.pow(.999, 844) + Math.pow(.999, 845) +
Math.pow(.999, 846) + Math.pow(.999, 847) + Math.pow(.999, 848) +
Math.pow(.999, 849) + Math.pow(.999, 850) + Math.pow(.999, 851) +
Math.pow(.999, 852) + Math.pow(.999, 853) + Math.pow(.999, 854) +
Math.pow(.999, 855) + Math.pow(.999, 856) + Math.pow(.999, 857) +
Math.pow(.999, 858) + Math.pow(.999, 859) + Math.pow(.999, 860) +
Math.pow(.999, 861) + Math.pow(.999, 862) + Math.pow(.999, 863) +
Math.pow(.999, 864) + Math.pow(.999, 865) + Math.pow(.999, 866) +
Math.pow(.999, 867) + Math.pow(.999, 868) + Math.pow(.999, 869) +
Math.pow(.999, 870) + Math.pow(.999, 871) + Math.pow(.999, 872) +
Math.pow(.999, 873) + Math.pow(.999, 874) + Math.pow(.999, 875) +
Math.pow(.999, 876) + Math.pow(.999, 877) + Math.pow(.999, 878) +
Math.pow(.999, 879) + Math.pow(.999, 880) + Math.pow(.999, 881) +
Math.pow(.999, 882) + Math.pow(.999, 883) + Math.pow(.999, 884) +
Math.pow(.999, 885) + Math.pow(.999, 886) + Math.pow(.999, 887) +
Math.pow(.999, 888) + Math.pow(.999, 889) + Math.pow(.999, 890) +
Math.pow(.999, 891) + Math.pow(.999, 892) + Math.pow(.999, 893) +
Math.pow(.999, 894) + Math.pow(.999, 895) + Math.pow(.999, 896) +
Math.pow(.999, 897) + Math.pow(.999, 898) + Math.pow(.999, 899) +
Math.pow(.999, 900) + Math.pow(.999, 901) + Math.pow(.999, 902) +
Math.pow(.999, 903) + Math.pow(.999, 904) + Math.pow(.999, 905) +
Math.pow(.999, 906) + Math.pow(.999, 907) + Math.pow(.999, 908) +
Math.pow(.999, 909) + Math.pow(.999, 910) + Math.pow(.999, 911) +
Math.pow(.999, 912) + Math.pow(.999, 913) + Math.pow(.999, 914) +
Math.pow(.999, 915) + Math.pow(.999, 916) + Math.pow(.999, 917) +
Math.pow(.999, 918) + Math.pow(.999, 919) + Math.pow(.999, 920) +
Math.pow(.999, 921) + Math.pow(.999, 922) + Math.pow(.999, 923) +
Math.pow(.999, 924) + Math.pow(.999, 925) + Math.pow(.999, 926) +
Math.pow(.999, 927) + Math.pow(.999, 928) + Math.pow(.999, 929) +
Math.pow(.999, 930) + Math.pow(.999, 931) + Math.pow(.999, 932) +
Math.pow(.999, 933) + Math.pow(.999, 934) + Math.pow(.999, 935) +
Math.pow(.999, 936) + Math.pow(.999, 937) + Math.pow(.999, 938) +
Math.pow(.999, 939) + Math.pow(.999, 940) + Math.pow(.999, 941) +
Math.pow(.999, 942) + Math.pow(.999, 943) + Math.pow(.999, 944) +
Math.pow(.999, 945) + Math.pow(.999, 946) + Math.pow(.999, 947) +
Math.pow(.999, 948) + Math.pow(.999, 949) + Math.pow(.999, 950) +
Math.pow(.999, 951) + Math.pow(.999, 952) + Math.pow(.999, 953) +
Math.pow(.999, 954) + Math.pow(.999, 955) + Math.pow(.999, 956) +
Math.pow(.999, 957) + Math.pow(.999, 958) + Math.pow(.999, 959) +
Math.pow(.999, 960) + Math.pow(.999, 961) + Math.pow(.999, 962) +
Math.pow(.999, 963) + Math.pow(.999, 964) + Math.pow(.999, 965) +
Math.pow(.999, 966) + Math.pow(.999, 967) + Math.pow(.999, 968) +
Math.pow(.999, 969) + Math.pow(.999, 970) + Math.pow(.999, 971) +
Math.pow(.999, 972) + Math.pow(.999, 973) + Math.pow(.999, 974) +
Math.pow(.999, 975) + Math.pow(.999, 976) + Math.pow(.999, 977) +
Math.pow(.999, 978) + Math.pow(.999, 979) + Math.pow(.999, 980) +
Math.pow(.999, 981) + Math.pow(.999, 982) + Math.pow(.999, 983) +
Math.pow(.999, 984) + Math.pow(.999, 985) + Math.pow(.999, 986) +
Math.pow(.999, 987) + Math.pow(.999, 988) + Math.pow(.999, 989) +
Math.pow(.999, 990) + Math.pow(.999, 991) + Math.pow(.999, 992) +
Math.pow(.999, 993) + Math.pow(.999, 994) + Math.pow(.999, 995) +
Math.pow(.999, 996) + Math.pow(.999, 997) + Math.pow(.999, 998) +
Math.pow(.999, 999);
System.out.println(System.currentTimeMillis() - start);
}
// StringBuffer s = new StringBuffer(" sum = 0");
// for (int n = 0; n < N; n++)
// s.append(" + Math.pow(.999, " + n + ")");
// s.append(";");
// System.out.println(s);
}
|
| |
|
| |
 |
Aaron Fude

|
Posted: 2004-12-18 11:40:00 |
Top |
java-programmer >> An efficient computation idea. Please comment
For the record, the computational efficiency you are suggesting speeds up
the code by a factor of 100. All I'm saying, why not speed it up by a factor
of 2 or 3 on top of that. (I think it would be even better than a factor of
2 or 3 on top of that since it's obvious that most of the time is spent
computing powers and not performing the loop. Once computing the powers is
removed and only looping remains, unwinding and compiling should make a big
difference.)
|
| |
|
| |
 |
bugbear

|
Posted: 2004-12-20 18:44:00 |
Top |
java-programmer >> An efficient computation idea. Please comment
Aaron Fude wrote:
I think a book on numerical analysis would serve
you better than one on compiler design.
BugBear
|
| |
|
| |
 |
Mark Thornton

|
Posted: 2004-12-21 3:18:00 |
Top |
java-programmer >> An efficient computation idea. Please comment
Aaron Fude wrote:
> For the record, the computational efficiency you are suggesting speeds up
> the code by a factor of 100. All I'm saying, why not speed it up by a factor
> of 2 or 3 on top of that.
You would be better off spending the time ensuring that the calculation
is numerically stable. As I indicated, a better understanding of
numerical analysis may well allow a far larger improvement in speed.
Mark Thornton
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- JTable and Custom Default Cell Editors
From: "Erica Wheatcroft" <email***@***.com>
Subject: JTable
Date: Thursday, January 20, 2005 4:17 PM
HI -
I have a jtable that uses two custom default cell editors to create combo
boxes for two of the the 4 columns. If the user selects another value from
either of the combo boxes i want to know that so i can indicate a save must
occur. I'm not sure what event i should listen to? Does any one have any
suggestions?
Thanks in advance.
Erica
- 2
- J2ME internationalizationI want to provide the binary with *only one* language, because I want to
be as small as I can.
But I want to provide many binaries (one per language).
So, I write the code with hardcoded strings like "$_nearest_dist_$".
I write a file like:
-----english.ini----
$_nearest_dist_$=Nearest distance is 90m
--------------------
and I write a php script which in *.java files, replaces all strings in
form "$_*_$" with language correct string.
php phpWriteStringsToSource.php <project_folder> <language.ini>
THE BIG PROBLEM: I realize that *.java files must have ansi* encoding!
Any of utf-8, uc16le or be is not compiled correct!
So, what I can do?
- 3
- Problem in configuring SSL in Tomcat5.5Hi,
I have Tomcat5.5 and J2sdk5 installed on my system. I wanted turn on
SSL services in tomcat. I went through the Tomcat Documentation and
did it exactly. I modified server.xml as below,
<!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
<Connector port="8443" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25"
maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
I also created certificate using keytool with default password as
"changeit" and alias as "tomcat".
I restarted the tomcat services too, and then tried to access the page
but i am not able to access it using https connection. Where as i am
able to access same page using Http connection.
Secondly, I am not able to access default tomcat Page too using Https
connection. Everything works fine in case of HTTP connection.
Following is the way iam trying to acces the page,
https://localhost:8443
Can any one help me out to find the problem.
I have IE 6 with SP2 installed on my system.
Thanks
Minesh
- 4
- passing RequestPath to error page from web.xmlHi,
I have pointed any errors to Error.jsp in my web.xml file (as shown).
<error-page>
<error-code>500</error-code>
<location>/Error.jsp?id=500</location>
</error-page>
As you can see I also pass the type of error, is there any way I can
pass the RequestPath that resulted in the error in the first place?
Cheers,
Paul
- 5
- How do i implement this interfacepublic interface AQuestion
{
public abstract void someMethod() throws Exception;
}
http://www.angelfire.com/or/abhilash/Main.html
see Question no 5.
How do i implement this interface ?
(1) problem is, it has an abstract method and hecne its complicated
to implement this class.
(2) another problem is, it is the public interface and hence we can not
make one more public class in the same file....because 1 file can have
only 1 public access specifier.
is it really possible to implement this interface ?
- 6
- Tomcat on Windows: JAVA_HOME & -Dsun.io.useCanonCaches'Apologies for posting this here, but I couldn't find any Tomcat user
forum.
A colleague is currently trying to run Tomcat 4.1.30 on Windows 2000
Professional. She first installed JRE2 1.4.2_08, and set %JAVA_HOME%
to the directory C:\j2re1.4.2_08 - I've run "java -version" and it
works fine.
(%JAVA_HOME%/home is in the path correctly).
She then installed Tomcat to C:\jakarta-tomcat-4.1.30.
However, when she runs catalina.sh start, she gets the following
error:
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
Using CATALINA_BASE: C:\jakarta-tomcat-4.1.30
Using CATALINA_HOME: C:\jakarta-tomcat-4.1.30
Using CATALINA_TMPDIR: C:\jakarta-tomcat-4.1.30\temp
Using JAVA_HOME: C:\j2re1.4.2_08
'-Dsun.io.useCanonCaches' is not recognized as an internal or external
command,
operable program or batch file.
I've even tried adding the following to catalina.bat without success:
if not "%JAVA_HOME%" == "" goto gotJavaHome
set JAVA_HOME=C:\j2re1.4.2_08
:gotJavaHome
Can anyone see where we might be going wrong?
Cheers,
P.
- 7
- Help to understand 'array of classes' exampleHi,
I'm trying to create/use an array of classes, and I found the following
code snippet using Google Groups:
...
rectangle[ ] array_name = new rectangle[ 100 ]; // or whatever
size
for ( int n = 0; n < 100; ++n )
{
array_name[ n ] = new rectangle( );
}
...
int i = 99;
int wide = array_name[i].getwidth( );
...
The above snippet was from:
http://groups.google.com/group/comp.lang.java.programmer/msg/1ea4bbde51104914
What I'm trying to understand in the above snippet is the line where the
array is initialized:
rectangle[ ] array_name = new rectangle[ 100 ]; // or whatever size
Before I found that post, I was trying something like:
rectangle [] arrayName; // declear an array of 'rectangle classes'
.
.
rectangle[0] = new rectangle(); // instantiate rectangle/populate array
rectangle[1] = new rectangle(); // instantiate rectangle/populate array
I did it that way because I don't know the number of classes that I'll
want to have in the array of classes ahead of time.
The code per the snippet from the cited posts works, but my original
code would get a NullPointerException, and I don't understand why.
Can someone explain this?
Also, is it possible to do this in a way that I don't have to allocate a
fixed size array?
Thanks,
Jim
- 8
- Simple GUI Image ProblemComputing student here, haven't used java for a while. Anyways, could someone put some example code as to how to put an image from a file onto a JPanel or JFrame. I just can't remember.
- 9
- Multiple installs of JDKWhen you do a silent install of the JRE you have the option to pass
PRIVATE=1, resulting in an install which doesn't check the registry
for a prior installation, and doesn't update the registry. You can
therefore have more than one install of the same JRE.
I need to find a similar capability for the JDK, but can't seem to. We
get rc=1603 on the second JDK install.
How can this be done...?
JDK >= 1.5.
{{{ Andy
- 10
- Running server-side Java on FreeBSD in production environments
So, I've seen a few mentions here of folks using Java server apps on
FreeBSD in production. I've been very happy to watch the progress by the
Java team on the native JDKs from the sidelines, as well as the
improvements to libc_r and such that have been MFC'd, but I'm curious as
to whether the consensus on this list is that it's ready to be used for
production. Anyone want to share good success or horror stories? We're
trying to determine whether the apache.org box can start to run our own
software. :) Speed is definitely less important than proper functioning.
Brian
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 11
- javax and macim running mac os 9.2 with MRJ SDK 2.2. im tring to compile a class
importing javax.swing.*; it says it cant find it. i unziped all the
jars and i cant find javax anywhere. is this not supported on this os.
- 12
- generate certificate from PEMHi,
I am developing a middleware solution for our companyy. I have got 2
certifcates clkey.pem and clcert.pem for the final application. How I
can combine these 2 keys in 1 certificate? Do I need to first create
self signed certificate?
Thx in advance.
- 13
- Still looking for a Job?
http://www.xrecruiter.com is a SPAM free Recruiter Community. Post
your resume for free, get noticed directly by recruiters. Register for
free.
- 14
- getting Error: could not find libjava.so Re: building a jdk1.5
On Mar 3, 2007, at 5:18 PM, Bill Moran wrote:
>
>> On Mar 3, 2007, at 4:01 PM, Chad Leigh -- Shire.Net LLC wrote:
>>
>>> Hi
>>>
>>> I am trying to build jdk15 inside my jail with PREFIX set to /usr/
>>> public (At one time I successfully got jdk 1.4 to build after much
>>> hacking)
>>>
>>> I have the option for builing inside a jail set. We get to the
>>> point where the linux java is installed and it is actually building
>>> the jdk
>>>
>>> # Start of jdk build
>>> /libexec/ld-elf.so.1: /usr/local/lib/libiconv.so.3: Undefined
>>> symbol "__mb_cur_max"
>>> *** Error code 1
>>>
>>> Stop in /usr/ports/java/jdk15.
>>> #
>>>
>>> I am not exactly sure what it is doing at this point in order to
>>> hack round it. libiconv a fresh install from ports
>>>
>>
>> Turns out that the issue is that gmake cannot run. I have not
>> figured out why yet, having removed and reinstalled libiconv and
>> gmake and getting the same error. But it is not java related.
>>
>> I'll redirect this to -questions
>>
>> If anyone has an idea on why gmake would fail as above on a fresh
>> install, 6.2-RELEASE from a day or two ago, I would appreciate it.
>> Please CC me as I am not currently subscribed to -questions, though I
>> am on -java
>
> Not a direct answer to your question, but when I needed to do this
> a few months ago, I just did a "make package" on my workstation, then
> shipped the package up to the jail system and installed it with
> pkg_add.
>
> Doesn't solve the problem, but if you're in a pinch, it's a handy
> workaround.
>
OK, I had never done this before -- built a package from a port. So
I did this on the base machine and then copied it into the jail and
did a pkg_add like so
# pkg_add -P /usr/public -v jdk-1.5.0p4_1.tbz
as I wanted it installed in my local policy dir /usr/public (which
gets mounted RO in every jail). My 1.4.2 java on my other jail
server is installed like this (but was built inside the jail many
moons ago).
Now, when I try to run java I get
# java -version
Error: could not find libjava.so
Error: could not find Java 2 Runtime Environment.
#
Java is in /usr/public/jdk1.5.0/ (the same as my 1.4.2 on the other
server which is in /usr/public/jdk1.4.2/). libjava.so is inside the
lib dir and I thought that java was referential to itself so it could
find its libraries.
I also tried setting JAVA_HOME and JRE_HOME though I have not had to
do that in a long time.
The new 1.5 jdk is registered in the javavms file .
When I run the javavm script with /bin/sh -x it does run the correct
java and running it with an explicit path does not help.
# /bin/sh -x /usr/public/bin/javavm -version
+ _JAVAVM_SAVE_PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/pub/
sbin:/usr/pub/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/
bin
+ export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+ _JAVAVM_PREFIX=/usr/public
+ _JAVAVM_CONF=/usr/public/etc/javavms
+ _JAVAVM_OPTS_CONF=/usr/public/etc/javavm_opts.conf
+ basename /usr/public/bin/javavm
+ _JAVAVM_PROG=javavm
+ _JAVAVM_MAKE=/usr/bin/make
+ [ javavm = javavm ]
+ echo javavm: warning: The use of 'javavm' as a synonym for 'java'
is deprecated
javavm: warning: The use of 'javavm' as a synonym for 'java' is
deprecated
+ _JAVAVM_PROG=java
+ [ -r /usr/public/etc/javavm_opts.conf ]
+ . /usr/public/etc/javavm_opts.conf
+ _JAVAVM_OPTS=
+ setJavaHome
+ realpath
+ realpath /usr/public
+ [ -n -a /stubs/usr_local/etc/ssmtp != /usr/public ]
+ unset JAVA_HOME
+ _JAVAVM_PORTSDIR=
+ [ -r /usr/share/mk/bsd.port.mk ]
+ /usr/bin/make -f /usr/share/mk/bsd.port.mk -V PORTSDIR
+ _JAVAVM_PORTSDIR=
+ _JAVAVM_BSD_PORT_MK=
+ [ -n -a -r /Mk/bsd.port.mk ]
+ [ -n ]
+ [ ! -e /usr/public/etc/javavms ]
+ sed -E s|[[:space:]]*#.*||
+ uniq
+ _JAVAVM_VMS=/usr/public/jdk1.5.0/bin/java
/usr/public/linux-sun-jdk1.4.2/bin/java
+ [ -n ]
+ dirname /usr/public/jdk1.5.0/bin/java
+ JAVA_HOME=/usr/public/jdk1.5.0/bin
+ dirname /usr/public/jdk1.5.0/bin
+ JAVA_HOME=/usr/public/jdk1.5.0
+ basename /usr/public/jdk1.5.0
+ _JAVAVM_VM=jdk1.5.0
+ [ -n ]
+ [ -n ]
+ [ -n ]
+ [ -n /usr/public/jdk1.5.0 -a -f /usr/public/jdk1.5.0/bin/java ]
+ _JAVAVM_PROG_PATH=/usr/public/jdk1.5.0/bin
+ return 0
+ [ 0 != 0 ]
+ [ -x /usr/public/jdk1.5.0/bin/java ]
+ basename /usr/public/jdk1.5.0
+ setJavaOptions java jdk1.5.0
+ echo java
+ sed -e s/\./_/g -e s/-/_/g
+ local OPTS_PROG=java
+ echo jdk1.5.0
+ sed -e s/\./_/g -e s/-/_/g
+ local OPTS_JAVA_HOME=jdk1_5_0
+ eval echo ${JAVAVM_OPTS_jdk1_5_0_java}
+ local JAVA_HOME_PROG_OPTS=
+ eval echo ${JAVAVM_OPTS_jdk1_5_0}
+ local JAVA_HOME_OPTS=
+ eval echo ${JAVAVM_OPTS_java}
+ local PROG_OPTS=
+ [ -n ]
+ [ -n ]
+ [ -n ]
+ [ -n ]
+ export JAVA_HOME
+ tryJavaCommand /usr/public/jdk1.5.0/bin/java -version
+ [ -n ]
+ [ -x /usr/public/jdk1.5.0/bin/java ]
+ [ -n /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/pub/sbin:/usr/
pub/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin ]
+ export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/pub/sbin:/
usr/pub/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
+ exec /usr/public/jdk1.5.0/bin/java -version
Error: could not find libjava.so
Error: could not find Java 2 Runtime Environment.
#
What did I do wrong?
Thanks
Chad
---
Chad Leigh -- Shire.Net LLC
Your Web App and Email hosting provider
chad at shire.net
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 15
- Initialize managed bean with header information?We use Netegrity's SiteMinder for SSO security on all web apps.
Although SiteMinder handles security for accessing the application
itself, restrictions to certain functions and data are handled within
the application based on user type.
The user information (such as name, type, etc.) are passed in from
SiteMinder via header variables. ie:
hddr_user = Joe Blo
hddr_group = Admin
hddr_phone = 555-555-5555
I'm looking at different designs to capture all of this user
information from the headers at one time and store as a bean in the
user's session (so as to not need to continually reference the header
information).
Does anyone know if you can create a managed bean (ie. User) that is
initialized with header information (by using the configuration file
w/ value-binding expressions)?
|
|
|