| performance and memory usage. |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- Removing Item From JList - getSelectedIndex problemHi all,
I am currently working on a JList that populates data into a JList
from a CSV file. I have a button that is supposed to get the Selected
index and then delete that item from the JList. Below is the code that
I am using:
int index = lstComputerExceptions.getSelectedIndex();
System.out.println("index is: " + index);
model.remove(0);
int size = model.getSize();
if (size == 0) { //Nobody's left, disable firing.
btnDelete.setEnabled(false);
} else { //Select an index.
if (index == model.getSize()) {
//removed item in last position
index--;
}
lstComputerExceptions.setSelectedIndex(index);
lstComputerExceptions.ensureIndexIsVisible(index);
}
I have printed out what index is and no matter what item I have in the
Jlist I have selected it will always print out
-1. Therefore keeps on causing my program to crash and not delete the
item out of the Jlist.
Any help in this matter would be highly appreicated.
Thank you
- 5
- JComboBox strange behaviorHello!
I have interesting problem with javax.swing.JComboBox (java 1.4.2)
When I click at combo to open list - there is no reaction to mouse
moves except these on combo header or outside my combo. So I cannot
choose any item from the list.
But I can use keyboard...
This is default combo, I've just create it and populate some Strings
into it.
any idea what's wrong?
B.
- 10
- Help needed (GUI/passing objects)
Hi, I'm a student learning java. In my latest assignment, I am to create a
Scheduler/Diary, with a GUI.
I am getting the error
Exception in thread "main" java.lang.NoSuchMethodError: BaseFrame: method
<init>
()V not found
at Dairy.main(Dairy.java:22)
From the main method in 'project.class', I create the diary object, which
creates month and day objects etc...
I create a state object, which takes in the Diary Object and points to the
selected month, day, appointment etc
I then create a gui object, which is to change the state (through methods in
the state).
This error occurs whenever I pass in the state object to the GUI
('BaseFrame').
Exception in thread "main" java.lang.NoSuchMethodError: BaseFrame: method
<init>
()V not found
at Dairy.main(Dairy.java:22)
I'm not sure whats causing this. I'm checking like 22 in the 'diary' class,
but it's a }. Not too helpful.
GUI appears when no state object is passed, can't manipulate the data with
that though....
In main:
------------
//set up the Diary
Diary dia = new Diary();
//set up the state
State diaryState = new State(dia);
//Set up the gui
BaseFrame firstFrame = new BaseFrame(diaryState);
---------------
When setting up the GUI:
---------------
State curState;
//constructor for the basic frame, takes in a state object
public BaseFrame(State sta)
{
curState = sta;
.....................}
--------------------------
Done a search online, didn't get too far. Any ideas? What does that error
mean exactly?
- 11
- 11
- Recognize Windows ShutdownHi,
how can i recognize that Windows is shutting down (when i'm logged off)?
Sorry for stupid questions, but i didn't found the right solution!
Greets,
Nico
-> remove the underscores in the email <-
- 11
- JNI: passing Objects containing non-primitive types back and forthHi folks,
looked through a lot a threads overhere already but did not find an
answer detailed enough:
I want to map a c-structure like this created in my native code
struct mystruct {
long pid ;
long data[] ;
long meta[][] ;
} ;
to a java-object within my Java-code which would look like this IMHO:
public class ComplexData {
final int maxdata = 100 ;
final int maxmeta = 5 ;
private long pid ;
private data[] = new long[maxdata] ;
private meta[][] = new long[maxdata][maxmeta] ;
public void ComplexData() {
// Assigning values
pid = 1234 ;
data[0] = ...
}...
As far as I understood it is now possible to pass this Java-object to
the native code using the JNI-Function NewObject and read the members
and assign their values to the c-structure's members (to make them
available from within c) and the other way round, assign the values
from the c-structure to the members within the Java-object (possibly
without the initialization in the "Java-world" (I need both
directions).
My problem now is: How do I access the object's members (especially
the array types) from within c? Functions pointed to in different
threads (e.g. (Get|Set)LongArrayRegion ) need the reference to the
array, but I have only the reference to the object up to now.
Any code snippets based on the code above would be helpful.
Cheers
Bernd
- 11
- Download a webpage that contains javascriptI am trying to download the html page at
http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1
Using the code
public class DownloadWebPage
{ public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1");
BufferedReader webRead = new BufferedReader(new
InputStreamReader(url.openStream()));
String line;
while ((line = webRead.readLine()) != null)
{
System.out.println(line);
}
}
}
But all I am getting is
<HTML><HEAD><SCRIPT
LANGUAGE="JAVASCRIPT">location.replace("http://www.dreamteamfc.com");</SCRIPT></HEAD></HTML>
I'm guessing that when the web brower meets this code it executes the
javascript
location.replace("http://www.dreamteamfc.com")
And somehow loads the web page.
How do I go about downloading the actual web page that gets displayed
in a normal web browser.
Any help appeciated!
pat
- 12
- 13
- PrintServiceLookup.lookupPrintServices fails to list new printers until re-start (JDK1.4.2_03, Linux RedHat, Tomcat 4.x)Hi Forum,
How could I get
javax.print.PrintServiceLookup.lookupPrintServices(null,null) to return the
current available services while the program that uses lookupPrintServices
is running? In a tomcat servlet I use the lookupPrintServices(..) to get a
list of the printer services available. The class works well and returns the
list but if I install a new printer, the servlet does not list the newly
installed service until I restart Tomcat. Is there a way to unload and
reload the PrintServiceLookup class and then call
PrintServiceLookup.lookupPrintServices?
It appears that the lookupPrintServices(..) returns the list of services
that was available when the instance of the virtual machine was started.
Hence, while the instance is running, it allways returns the same list of
services. If I run a program that lists the services and then exits, the
program lists the newly added printer on re-run. But if the program never
exits (it runs in a loop, re-listing the services every so often), and I add
a new printer while the program is running, the newly added printer is not
listed until I terminate teh rpogram and re-start it.
Thanks in advance for your responser
- 13
- Java encryption <--> .NET encryptionHajo,
I need to exchange encypted data between
.NET and Java environments. The first
problem I encountered is that symmetric
ciphers in .NET needs initialization
vector and Java counterparts don't.
Can some one point me out the place
where I can find any practise and
patterns for encrypted communication
between Java and .NET ?
thanks for any info
Gawel
- 13
- Java FACT ?"FACT: Java has no first-class functions and no macros. This results in
warped code that hacks around the problem, and as the code base grows,
it takes on a definite, ugly shape, one that's utterly unique to Java.
Lisp people can see this clear as day. So can Python folks, so can Ruby
folks. Java people flip out, and say "macros are too much power",
or "what do u mean i dont understand u" or "fuck you, you jerk,
Lisp will NEVER win". -- Steve Yegge, 2006-04-15
what would you people make of the above statement ? Has anyone here
used Lisp *and* Java on major projects ? If so would you say this
sounds off-base or correct ?
thanks,
--dcnstrct
- 15
- java/81177: java patch server down
>Number: 81177
>Category: java
>Synopsis: java patch server down
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: freebsd-java
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Tue May 17 20:30:07 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: Ron
>Release: FreeBSD 5.4-STABLE i386
>Organization:
>Environment:
System: FreeBSD justok.thuisnetwerk.nl 5.4-STABLE FreeBSD 5.4-STABLE #0: Sat May 14 16:24:15 CEST 2005 email***@***.com:/usr/obj/usr/src/sys/MYKERNEL i386
>Description:
jdk14 and jdk15 can not be installed, because http://www.eyesbeyond.com/freebsddom/java/jdk15.html is down.
<code/input/activities to reproduce the problem (multiple lines)>
Use any webbrowser to visit the URL, and see that it's down.
>How-To-Repeat:
>Fix:
Someone should bring up the webserver or let the URL point to a webserver that is up.
>Release-Note:
>Audit-Trail:
>Unformatted:
- 15
- Precision problem with doubleHi everyone,
I am a Java beginner, and I am trying to create a very simple binary
tree.
Each node has a value, the left child has the same value + an
increment, the right child has the same value - the same increment.
I try to recursively create the tree, but I have precision problems.
My "main" node has a value of 10, the increment is 0.1, tree depth is
4
So i want a tree that goes like this :
depth 1 : 10
depth 2 : 0.9 / 10.1
depth 3 : 0.8 / 10 / 10 / 10.2
depth 4 : 0.7 / 0.9 / 0.9 / 10.1 / 0.9 / 10.1 / 10.1 / 10.3
But at depth 4 when I try to print the value I get 9.700000000000001
instead of 9.7, and 10.299999999999999 instead of 10.3
And things get worse when the depth increase.
All the values and increment are stored in double (native type).
Is it normal? How can I avoid this problem?
Thanks a lot,
Tom.
[main class]
double increment = 0.1;
double startValue = 10;
int maxDepth = 4;
Tree myTree = new Tree(startValue, 1);
myTree.recursivelyCreateChildren(increment, maxDepth);
[Tree.java]
public int depth;
public double value;
public Tree leftChild;
public Tree rightChild;
Tree(double value, int depth){
this.value=value;
this.depth=depth;
System.out.println("node of depth " + depth + " created, value = " +
value);
}
public void createChildren(double increment){
rightChild = new Tree(value - increment, depth+1);
leftChild = new Tree(value + increment, depth+1);
}
public void recursivelyCreateChildren(double increment, int maxDepth)
{
if (depth < maxDepth){
createChildren(increment);
leftChild.recursivelyCreateChildren(increment, maxDepth);
rightChild.recursivelyCreateChildren(increment, maxDepth);
}
}
- 16
- SET CLASSPATHhi, i'm using the abstract class definition, and when compiling the abstract
class it's ok, but the problem is when compiling the subclass: i get the
following message:
Rect.java:9: cannot resolve symbol
symbol : class GeoFigure
location: class figures.Rect
public class Rect extends GeoFigure
^
1 error
the abstract class is called: GeoFigure;
and the subclass is Rect
so how cn use the set classpath at command line, should it include the
directory where are located all the package files(the abstract class and
subclass .java files), or should it point at onel evel before the directory
that contains the package files?
thank's!
--
SAID BARA
- 16
- Vetoing a change by DefaultCellEditor in JTableI'm using a DefaultCellEditor with a JTextField to capture a String
that is ultimately passed to setValueAt in my TableModel. In that
method, I have logic which could throw an exception if the String's
contents proves to be invalid (i.e. one use is where the String is a
regular expression that might be syntactically invalid).
How can I handle this? Right now, the code throws an Exception which
I'd like to catch, display a dialog, and then return the user to
editing without ever committing the value. Is this easily doable?
Regards,
Brian.
|
| Author |
Message |
arnold

|
Posted: 2006-2-12 8:02:00 |
Top |
java-programmer, performance and memory usage.
Hi
I created a test program to try the speed and size management of the JDK
HashMap. With regards to this I was wondering if anybody has any
comments on whether this is an appropriate way of testing this
performance, i.e. how realistic is the results with respect to caching
influence of data, heap management etc. The code is simple, but would it
produce a correct result. (the program finishes in 11 seconds on my
machine). the code is attached.
Secondly, I was wondering about the memory (heap) usage in java for this
program. It needs at least 256 MB of heap to run to finish. cmd:
java -Xms32m -Xmx256m -cp target/classes/ App
Using -Xmx128m causes OutOfMemoryError.
When calculating on the size of the datastructure i find approx that
2M Dto's = 16MB
2M Integer's for map key = 8MB
2M Integer's for ArrayList = 8MB
Thats a total of 32MB plus some megabytes for the objects,
datastructures, JVM and so on. So probably about 48-64MB in total.
Thats a completely different number from 128 MB or 256 MB.
Does anybody have any comments on why the program requires that much memory?
arnie
*****************
/* Create 2 million Dto objects with random data and insert into HashMap
also add key to an iterable list */
public void test1() {
int size = 2000000;
Map<Integer, Dto> hmap = new HashMap<Integer, Dto> (size);
Collection<Integer> alist = new ArrayList<Integer> (size);
Random r = new Random();
Dto data;
for (int c=size; c>0; c--) {
data = new Dto();
data.ip= r.nextInt(2000000000);
hmap.put(data.ip, data);
alist.add(data.ip);
}
int c = 1;
for (Integer d : alist) {
hmap.get(d);
}
}
/* Simple data placeholder */
public class Dto
{
public int ip;
public int serialnum;
}
|
| |
|
| |
 |
Chris Smith

|
Posted: 2006-2-12 12:21:00 |
Top |
java-programmer >> performance and memory usage.
arnold <email***@***.com> wrote:
> java -Xms32m -Xmx256m -cp target/classes/ App
>
> Using -Xmx128m causes OutOfMemoryError.
>
> When calculating on the size of the datastructure i find approx that
>
> 2M Dto's = 16MB
> 2M Integer's for map key = 8MB
> 2M Integer's for ArrayList = 8MB
First of all, your Dto class requires 8 bytes just for fields alone.
Add to that at LEAST 8 bytes for an object header. That's 32MB at a
minimum. The ArrayList needs four bytes per entry just for a pointer to
the Integer object... that's another 8 MB. The Integer object itself
has 4 bytes of data, and again at least 8 bytes of object header, so
that's 24 MB. The HashMap data storage is complicated to estimate, but
even completely ignoring the bucket pointers and structure, you still
have 4 bytes for a pointer to the Dto and 4 bytes for a pointer to the
integer... plus, since the field of Dto is of type int, there's a
separate boxing conversion for the HashMap and a new set of Integer
objects, so that's another 8 MB + 8 MB + 24 MB = 40 MB. Total so far:
104 MB, and that's assuming minimal object header size and a magical
hashmap that requires no overhead for internal data structures.
Of course, you need some spare memory for any dynamic memory allocation
algorithm. For a free list (C++-structured), that would be about 8
bytes per object, or at least an extra 48 MB. For a more realistic
garbage collected system, this varies a lot more... but a good rule of
thumb is to multiply the memory requirement by two if you want decent
performance, meaning at least an extra 104 MB.
So, this easily accounts for running out of memory with 128 MB. In
fact, it's quite likely that you're memory-starving the garbage
collector with 256 MB, and would do better time-wise to provide a little
more.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
arnold

|
Posted: 2006-2-12 18:04:00 |
Top |
java-programmer >> performance and memory usage.
Chris Smith wrote:
> So, this easily accounts for running out of memory with 128 MB. In
> fact, it's quite likely that you're memory-starving the garbage
> collector with 256 MB, and would do better time-wise to provide a little
> more.
Thats actually quite terrible memory utilisation. In that case I have
some questions:
1- Is there a more efficient way of storing this in memory, so you could
store up to, say, 100 million objects?
2- Is there a method of creating simple data placeholders which are not
objects, similar to structs in c/c++.
3- Are there any methods of making the data structures themselves more
memory efficient.
In C I could write this so the program would not require more than
approx 48MB. (where approx 32MB is the real data and 16 MB is the arrays
with the pointers to the structures containing the data).
To me its seems that you should not really use java for in-memory
storage, except for smaller data sets.
arnie
|
| |
|
| |
 |
Roedy Green

|
Posted: 2006-2-12 20:00:00 |
Top |
java-programmer >> performance and memory usage.
On Sun, 12 Feb 2006 01:02:26 +0100, arnold <email***@***.com> wrote,
quoted or indirectly quoted someone who said :
>Does anybody have any comments on why the program requires that much memory?
One problem is your HashMap size is wrong. You don't specify the
number of elements you want to hold, but the capacity. You must allow
some slop at least enough to account for the load factor.. It ran out
of room and had to double the size temporarily holding both old and
new.
See http://mindprod.com/jgloss/hashmap.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
Chris Smith

|
Posted: 2006-2-13 1:19:00 |
Top |
java-programmer >> performance and memory usage.
arnold <email***@***.com> wrote:
> Thats actually quite terrible memory utilisation.
It's not all that bad; you're just storing a lot of data. In any case,
it's a realtively small constant multiple of what you'd get from any
other language.
> In that case I have some questions:
>
> 1- Is there a more efficient way of storing this in memory, so you could
> store up to, say, 100 million objects?
> 3- Are there any methods of making the data structures themselves more
> memory efficient.
There are a few things you could do, if you're really desperate. For
example, you can save a lot of space by re-implementing HashMap and
ArrayList to use primitive int data instead of pointers to objects of
class Integer.
> 2- Is there a method of creating simple data placeholders which are not
> objects, similar to structs in c/c++.
No.
> In C I could write this so the program would not require more than
> approx 48MB. (where approx 32MB is the real data and 16 MB is the arrays
> with the pointers to the structures containing the data).
No, you couldn't. You're still ignoring the overhead for memory
allocation data structures. That overhead exists in C as well as in
Java.
The only difference is that in Java, objects carry an additional 8 bytes
or so of object header, and that the HashMap and ArrayList classes work
with Object and not int (solvable, as I mentioned, if you are willing to
re-implement those classes).
> To me its seems that you should not really use java for in-memory
> storage, except for smaller data sets.
You should, ideally, use a database for storing large data sets.
Ideally, you wouldn't implement your own database anyway, in any
language.
It's definitely possible to implement a database in Java if you so
desire, but you wouldn't store everything in object-oriented data
structures; instead, you'd use memory mapped files and java.nio.Buffer
to access the data. In-memory data structures are designed to be
convenient and capable for manipulating working data, not to be an
efficient means of data storage.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
tom fredriksen

|
Posted: 2006-2-13 4:21:00 |
Top |
java-programmer >> performance and memory usage.
Chris Smith wrote:
> arnold <email***@***.com> wrote:
> There are a few things you could do, if you're really desperate. For
> example, you can save a lot of space by re-implementing HashMap and
> ArrayList to use primitive int data instead of pointers to objects of
> class Integer.
I suppose there are some libraries which has alredy done these
implementations.
>>Thats actually quite terrible memory utilisation.
>
> It's not all that bad; you're just storing a lot of data. In any case,
> it's a realtively small constant multiple of what you'd get from any
> other language.
>
>>In C I could write this so the program would not require more than
>>approx 48MB. (where approx 32MB is the real data and 16 MB is the arrays
>>with the pointers to the structures containing the data).
>
>
> No, you couldn't. You're still ignoring the overhead for memory
> allocation data structures. That overhead exists in C as well as in
> Java.
how so? Yes, its a lot of data, but the point is that the data is only
about 32MB of pure data, the rest of the approx 150MB are internal data
for the structures and objects etc (I tested the limits). That yields a
utilisation percentage of 15%, which is quite terrible.
In C what you need is a hash array of 4 bytes per entry, and a second
array for iteratiing the keys of 4 bytes per entry. then there is the
hash data which is 8 bytes per entry. Thats 4 + 4 + 8 * 2million which
is 32MB, and that includes all intrinsic data the strucures need. If I
am missing something please let me know.
(the hash structure might need some more space (i dont know the actual
implementation of the function), but its most likely not more than an
additional 4-8 bytes per entry, and that would take us up to 48MB.
>>To me its seems that you should not really use java for in-memory
>>storage, except for smaller data sets.
>
> You should, ideally, use a database for storing large data sets.
> Ideally, you wouldn't implement your own database anyway, in any
> language.
Databases and network operations are slow and costly (in money for
customer solutions), plus you then have an additional 2-3 programming
tiers, in addition the customer gets unnecessary system maintenance.
I am a bit sick of the notion in todays programming world that
everything can only be solved by another heavyweight system which is
excruciately complex to use and costs an arm and a leg in money and
maintenance. Thats just a waste of money and time. Most problems can be
solved by much simpler solutions (which are just as adaptable, scalable
and possibly contains inherent maintenance), than the
tomcat/struts/IBM/BEA/ORACLE/SAP type solutions. Considered BerkleyDB?
JavaSpaces? Hashmap with ReiserFS? The problem is that most people dont
realise this, so there are'nt many good or well known solutions for such
systems.
arnie
|
| |
|
| |
 |
arnold

|
Posted: 2006-2-13 4:26:00 |
Top |
java-programmer >> performance and memory usage.
Chris Smith wrote:
> arnold <email***@***.com> wrote:
> There are a few things you could do, if you're really desperate. For
> example, you can save a lot of space by re-implementing HashMap and
> ArrayList to use primitive int data instead of pointers to objects of
> class Integer.
I suppose there are some libraries which has alredy done these
implementations.
>> Thats actually quite terrible memory utilisation.
>
>
> It's not all that bad; you're just storing a lot of data. In any case,
> it's a realtively small constant multiple of what you'd get from any
other language.
>
>> In C I could write this so the program would not require more than
approx 48MB. (where approx 32MB is the real data and 16 MB is the arrays
with the pointers to the structures containing the data).
>
>
>
> No, you couldn't. You're still ignoring the overhead for memory
allocation data structures. That overhead exists in C as well as in Java.
how so? Yes, its a lot of data, but the point is that the data is only
about 32MB of pure data, the rest of the approx 150MB are internal data
for the structures and objects etc (I tested the limits). That yields a
utilisation percentage of 15%, which is quite terrible.
In C what you need is a hash array of 4 bytes per entry, and a second
array for iteratiing the keys of 4 bytes per entry. then there is the
hash data which is 8 bytes per entry. Thats 4 + 4 + 8 * 2million which
is 32MB, and that includes all intrinsic data the strucures need. If I
am missing something please let me know.
(the hash structure might need some more space (i dont know the actual
implementation of the function), but its most likely not more than an
additional 4-8 bytes per entry, and that would take us up to 48MB.
>> To me its seems that you should not really use java for in-memory
storage, except for smaller data sets.
>
>
> You should, ideally, use a database for storing large data sets.
Ideally, you wouldn't implement your own database anyway, in any language.
Databases and network operations are slow and costly (in money for
customer solutions), plus you then have an additional 2-3 programming
tiers, in addition the customer gets unnecessary system maintenance.
I am a bit sick of the notion in todays programming world that
everything can only be solved by another heavyweight system which is
excruciately complex to use and costs an arm and a leg in money and
maintenance. Thats just a waste of money and time. Most problems can be
solved by much simpler solutions (which are just as adaptable, scalable
and possibly contains inherent maintenance), than the
tomcat/struts/IBM/BEA/ORACLE/SAP type solutions. Considered BerkleyDB?
JavaSpaces? Hashmap with ReiserFS? The problem is that most people dont
realise this, so there are'nt many good or well known solutions for such
systems.
arnie
|
| |
|
| |
 |
arnold

|
Posted: 2006-2-13 4:27:00 |
Top |
java-programmer >> performance and memory usage.
Roedy Green wrote:
> On Sun, 12 Feb 2006 01:02:26 +0100, arnold <email***@***.com> wrote,
> quoted or indirectly quoted someone who said :
>
>
>>Does anybody have any comments on why the program requires that much memory?
>
>
> One problem is your HashMap size is wrong. You don't specify the
> number of elements you want to hold, but the capacity. You must allow
> some slop at least enough to account for the load factor.. It ran out
> of room and had to double the size temporarily holding both old and
> new.
>
> See http://mindprod.com/jgloss/hashmap.html
Theoretically it might be true, but it made no practical difference. I
tried increasing the size of both the Map and the Collection by a
multiple of 2 and 4 and decreased the heap size, it made no difference.
Both this change and the original code needed approx 180MB of heap to work.
arnie
|
| |
|
| |
 |
Chris Smith

|
Posted: 2006-2-13 6:13:00 |
Top |
java-programmer >> performance and memory usage.
tom fredriksen <email***@***.com> wrote:
> I suppose there are some libraries which has alredy done these
> implementations.
Well, maybe. For integers, yes there probably are. You can save much
more space by inlining the custom data structure into the hash table
entries as well, and obviously that would not pre-exist.
Assuming you want to just inline ints... for ArrayList, the complexity
of an extra dependency on some third-party code is probably not worth
saving the couple dozen lines of code to do this on your own. The
HashMap will be more complex, and may be worth the new dependency.
> >>In C I could write this so the program would not require more than
> >>approx 48MB. (where approx 32MB is the real data and 16 MB is the arrays
> >>with the pointers to the structures containing the data).
> >
> >
> > No, you couldn't. You're still ignoring the overhead for memory
> > allocation data structures. That overhead exists in C as well as in
> > Java.
>
> how so?
Dynamic memory management is not magical in C. It uses data structures
to work, just like anything else. Those data structures are typically
stored in the bytes directly before the memory address that's returned
to you from a call to malloc. You are assuming that when you write
"malloc(8)", that requires 8 bytes of memory. In reality, it requires
about twice that amount, depending on the malloc implementation.
Ignoring this makes your comparison unreliable.
Incidentally, I'm still ignoring malloc overhead from memory
fragmentation. This overhead won't show up in a simple test program,
but will become larger over time in a long-running application,
generally asymptotically approaching a constant proportion of the total
memory requirement. Modern malloc implementations are pretty good, so
if you wanted to include this, you'd generally assume this memory is
about 20% or so of the actual memory in use. This is worth mentioning,
because this fragmentation would not be present in Java, in which
defragmentation is generally a side-effect of garbage collection.
> (the hash structure might need some more space (i dont know the actual
> implementation of the function), but its most likely not more than an
> additional 4-8 bytes per entry, and that would take us up to 48MB.
Okay, let's get more specific.
I'll assume you use a straight-forward implementation of a general-
purpose hash table written in C. A hash table will require a set of
buckets, and a linked list of data for each bucket. On a 32-bit
machine, that's about 8 MB divided by the load factor, for the bucket
heads. The linked list for the data will contain a pointer to the data
itself, a pointer to the key, and a pointer to the next piece... plus
possibly a cached hash value, but we'll ignore that by assuming you've
chosen an implementation that opts for mem0ory compactness instead of
performance. That is an extra twelve bytes per entry of visible
overhead, plus about eight bytes per entry of memory management
overhead. You'll need to dynamically allocate space for the keys, so
that's an extra 4 bytes of visible memory, plus 8 bytes of allocation
overhead. Assuming a load factor of 2, that brings us to 4 MB
+ (n * 20) + (n * 12), which is a total of 68 MB of overhead for the
hash table.
You can eliminate about 32 MB of that 68 MB by writing your own hash
table, in which case you could inline the data and keys into your hash
entry structure and save the pointers and dynamically allocated keys.
Similar savings can be had by using C++ templates, and would be expected
in TR1's STL hash structure for example.
So we have an additional overhead of either 68 MB or 36 MB, depending on
your implementation choices. The total for C is either 100 MB or 68 MB,
not counting some negligible other sources of memory requirement.
So let's take the answer to be 68 MB. In Java, if you similarly write
your own data structures to inline the data, you'd use an additional 16
MB on top of that, for a total of 84 MB. Leaving space for the garbage
collector to work, you might expect 128 MB to be sufficient (remember
that we already accounted for about eight bytes per object that aren't
needed in a Java garbage collector since there's generally no explicit
free list, so we don't need to double it).
Or let's take the answer to be 100 MB if you don't want to write your
own hash table. In Java, you'll get an additional 48 MB, for a total of
148 MB. Make that about 200 MB for reasonable garbage collector
performance (same note about not needing the overhead to keep a free
list).
Or, if you want to use an ArrayList of Integer in Java instead of
managing your own int[], then the memory requirement goes up to 188 MB,
or maybe 256 MB for reasonable gc performance. There has been no C
equivalent proposed for such a design, but it would probably require
about 124 MB of memory (similar methods).
So, overall, it appears that Java requires about twice the memory of C
for all possible design alternatives. C++ shows a considerable
advantage, though, in that you can use STL data structures vector and
TR1's unordered_map, and get the 68 MB result without having to re-
implement anything.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Roedy Green

|
Posted: 2006-2-13 17:43:00 |
Top |
java-programmer >> performance and memory usage.
On Sun, 12 Feb 2006 10:19:21 -0700, Chris Smith <email***@***.com>
wrote, quoted or indirectly quoted someone who said :
>There are a few things you could do, if you're really desperate. For
>example, you can save a lot of space by re-implementing HashMap and
>ArrayList to use primitive int data instead of pointers to objects of
>class Integer.
One goofy thing about HashMap vs the way it used to be done is there
are three objects for each entry, a key, an object and a piece of glue
to tied them together with overflow chains.
In the olden days you, might have left a slot in the object itself for
the chains, and used a key embedded in the object. You then have only
one object per item.
The problem with that sort of old-fashioned implementation is you
must think ahead and leave a slot in your objects for HashSet to use,
and you can't put the object in more than one HashSet.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
megagurka

|
Posted: 2006-2-13 18:13:00 |
Top |
java-programmer >> performance and memory usage.
arnold skrev:
> Chris Smith wrote:
>
> > So, this easily accounts for running out of memory with 128 MB. In
> > fact, it's quite likely that you're memory-starving the garbage
> > collector with 256 MB, and would do better time-wise to provide a little
> > more.
>
> Thats actually quite terrible memory utilisation. In that case I have
> some questions:
>
> 1- Is there a more efficient way of storing this in memory, so you could
> store up to, say, 100 million objects?
> 2- Is there a method of creating simple data placeholders which are not
> objects, similar to structs in c/c++.
> 3- Are there any methods of making the data structures themselves more
> memory efficient.
Try these primitive type collection libraries:
http://pcj.sourceforge.net/
http://trove4j.sourceforge.net/
/JN
|
| |
|
| |
 |
Roedy Green

|
Posted: 2006-2-13 18:32:00 |
Top |
java-programmer >> performance and memory usage.
On 13 Feb 2006 02:13:13 -0800, "megagurka" <email***@***.com>
wrote, quoted or indirectly quoted someone who said :
>Try these primitive type collection libraries:
>
>http://pcj.sourceforge.net/
>http://trove4j.sourceforge.net/
for even more see http://mindprod.com/jgloss/collection.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
arnold

|
Posted: 2006-2-13 21:35:00 |
Top |
java-programmer >> performance and memory usage.
Chris Smith wrote:
> Okay, let's get more specific.
Please see attached code sample.
First of, I've implemented this using the C language idioms, which one
should do instead of trying to copy the java or OO idioms.
Secondly, you should be aware of one thing about this implementation.
That is that the hash table implementation uses character keys, not
integer keys as my java implementation. In order to accomodate this I
needed to create a string represenation of the key, So this adds a
modest size to the program. Also I dont know how much memory the table
allocates for a 2mill entry table, show that should add some extra
compared to HashMap, All in all its still smaller than your optimal C++
impl. and about 3-4 times smaller than my java impl. (With 4 Gigs of
memory this program would be able to store 125 million entries, while
the java version would store 48 million entries)
FYI, this program took 3.18 seconds to complete the full implementation,
where as my java version needed 11 seconds.
Here are the memory stats for this program. The VIRT column is the most
representative, allthough it includes code and libraries sizes. You can
use the DATA column if you like, though.
Test 1: No datastructures allocated,
PID VIRT RES SHR SWAP CODE DATA COMMAND
24125 1432 280 1400 1152 8 1424 hash
Test 2: Allocating an iteration array of 2M entries
PID VIRT RES SHR SWAP CODE DATA COMMAND
24134 9248 316 1400 8932 8 9240 hash
Test 3: Allocating the hashtable with no data
PID VIRT RES SHR SWAP CODE DATA COMMAND
24573 32688 30m 1400 1100 8 31m hash
Test 4: Full implementation
PID VIRT RES SHR SWAP CODE DATA COMMAND
24753 63972 61m 1400 1096 8 62m hash
************ code **************
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <search.h>
/* Placeholder for data */
typedef struct dto {
int ip;
int serialnum;
} dto_t;
int main(int argc, char **argv)
{
int *key = NULL; /* The key array for iterating the hash */
int size = 2000000; /* The number of entries*/
if (!hcreate((size_t) size)) {
printf("Error creating hashtable\n");
exit(0);
}
int r = 0;
dto_t *data = NULL;
ENTRY e, *ef;
char r_str[20];
/* Create data and insert into hash and key array */
key = malloc(sizeof(int) * size);
for(int c=0; c<size; c++ ) {
/* A random number between 1 and 2billions */
r = 1+(int) (2000000000.0*rand()/(RAND_MAX+1.0));
key[c] = r;
sprintf(r_str, "%i", r);
e.key = r_str;
data = malloc(sizeof(data));
data->ip = r;
e.data = (dto_t *)data;
hsearch(e, ENTER);
}
/* Iterate the key array and retrieve hash data */
for(int c=0; c<size; c++ ) {
sprintf(r_str, "%i", key[c]);
e.key = r_str;
ef = hsearch(e, FIND);
if(ef)
data = (dto_t *) ef->data;
}
return(0);
}
|
| |
|
| |
 |
megagurka

|
Posted: 2006-2-13 22:47:00 |
Top |
java-programmer >> performance and memory usage.
arnold skrev:
> Chris Smith wrote:
> > Okay, let's get more specific.
>
> Please see attached code sample.
>
> First of, I've implemented this using the C language idioms, which one
> should do instead of trying to copy the java or OO idioms.
AFAICT there is nothing that stops you from implementing the same data
structure in Java as you do in C.
/JN
|
| |
|
| |
 |
arnold

|
Posted: 2006-2-13 23:01:00 |
Top |
java-programmer >> performance and memory usage.
megagurka wrote:
> arnold skrev:
>
>>Chris Smith wrote:
>>
>>>Okay, let's get more specific.
>>
>>Please see attached code sample.
>>
>>First of, I've implemented this using the C language idioms, which one
>>should do instead of trying to copy the java or OO idioms.
>
>
> AFAICT there is nothing that stops you from implementing the same data
> structure in Java as you do in C.
Thats true, but in a real scenario it would be relevant for the hashmap
only. I dont know how much more efficient it would be though. (the
arraylist is of no interrest, since it only used for testing. In any
case it can be implemented as a pure int array.)
/arnie
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Hibernate and Eclipse -- where to start?Hi folks,
This began as a thread in comp.lang.java.programmer, but the focus has
really moved toward db stuff, so I repost bits here. For the full
thread, see "searching for yoda - a developer's tale" at:
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_frm/thread/aa12c688b702cc72/f769b8aebe720db5?_done=%2Fgroup%2Fcomp.lang.java.programmer%2Fthreads%3Fstart%3D0%26order%3Drecent%26&_doneTitle=Back&&d#f769b8aebe720db5
[...] how to fit Hibernate into Eclipse. Again, my problem statement
is that I naturally work with objects and object graphs and would
prefer to spend most of my development effort in this domain. I would
like as much as possible to have mapping and schema handled by the
tool. It *seems* to me that the "natural" mode for Hibernate is to
start with the mapping and use the tools to generate Java and schema.
This is still better than starting with a relational model.
The learning required for these technologies is what I'm confused
about. What exactly do I need to learn? I have a couple of Hibernate
books (the "in Action" is one of them and is, so far, quite good). The
API seems reasonable and not too intimidating. If I were still a
vi/JDBC coder, I would simply add Hibernate API as a tool and
incrementally move forward. But, now that I'm a full-fledged Eclipse
user and committed to focusing on the object model, I'd like to (1)
integrate Hibernate into Eclipse (via any of the afore-mentioned
plug-ins or others), and (2) try to work from the object side of ORM.
Online docs for the plug-ins to solve (1) seem weak. It's hard to tell
which plug-in does what, and what the advantages/disadvantages of each
might be. (2) seems to imply, from my reading, a need for XDoclet or
some other Attribute-Oriented solution to bury the necessary hibernate
tags into the code. Once again, the docs I've found seem weak. More to
the point, as I've mentioned, each new link leads to five others and
their associated technology requirements...It just gets out of hand
quickly. My hope is for someone here to point the way through the fog
and say "here's how to integrate Hibernate" or perhaps "don't bother
integrating Hibernate, use this basic config file and modify as
needed", etc.
Any guidance would be greatly appreciated.
-don.
- 2
- Location of Temp Directory?I'm having an app developed for me and they are storing the files in a
newly created folder on the C: drive but I don't want to make directory
there. Is there not a way to get the temp variable for machine, like
%temp or %tmp? Thanks
- 3
- Java Application Programmer for Oracle/Win Envir
Title: Java Application Programmer for Oracle/Win Envir.
Skills: Java Coder/Application Programmer (Web-Based Apps), SQL,
Oracle 8i or 9i, STRUTS
Trinity Consultancy Services is seeking applications from qualified
and experienced software engineers with above skills for various
requirements with their Clients.
Job description:
Java Coder/Application Programmer
We are seeking a Java developer to code applications and code Java
Classes from scratch to help in the development of an nth-tier web
application using Java language and associated technologies, in an
Oracle 8i/9i and Windows environment.
Duties and Responsibilities:
* This position requires a strong Java Application coder (3 years).
Ability to code applications from scratch by writing basic Java code
plus the ability to compile Java Applications using Java Servlets,
Applets, JSP's and JavaBeans. Must be able to create JavaBeans from
scratch. Should be able to track down particular Java code lines,
Scripts, JSPs, Beans, Servlets or Applets.
Required Experience:
* At least 3 years hands-on paid software development experience in
design and coding of Web applications.
* At least 3 years in Java and Object-Oriented software development.
* Experienced in Windows Dev.
* Experienced in large-scale, enterprise systems implementation with
through understanding of system development methodology.
* Must have STRUTS experience.
Required Skills:
* Strong computer programming skills in Java coding of Java Classes
and OO Design.
* Strong programming skills in programming with SQL and Oracle 8i/9i
Database.
* Strong programming skills in J2EE technologies, such as JSP, Java
Servlet, Javabean, EJB, JNDI, MVC, and JDBC API.
* Must have STRUTS experience.
* Good working skills in using Http, SSL, JDBC, RMI, XML, JMS.
* Good working skills in using Windows OS (XP, NT, 2000).
* Good interpersonal and communications skills.
Education:
Bachelor degree, CS or equivalent required.
Trinity Consultancy Services is a leading source of Information
Technology, Engineering and Management Experts that corporations of
all sizes turn to, from Global 2000 corporations to mid-sized and
small organizations nationwide. With the commitment to excellence, is
subtly managed to find, recruit, screen, submit and effectively
organize a technical workforce anywhere in the United States for
various Technical needs of corporation irrespective of its size.
Trinity Consultancy Services is one of its unique kind of the leading
information technology consulting services, and business process
outsourcing organizations committed for excellence.
Trinity provides business consulting, systems integration, application
development, staffing services and managed services to Global 2000
Corporations, medium-sized businesses, and government organizations
throughout the United States.
Trinity can mobilize the right resources, skills and technologies to
enable our clients to reach their dreams by enhanced performance. With
deep industry and business process expertise and broad global
resources, Trinity Consultancy Services is committed for excellence.
Please contact our Human Resource Manager Ms. Ann and send your
detailed Resume with your work authorization status, current salary
and expectations.
Mention the position you are applying in the subject line.
Email: email***@***.com
www.trinityconsultancy.com
- 4
- Image Processing Problem. Need HelpHello, I am writing a web application with Java. There is a function that
user can upload a picture to server, and the server will resize it. I am
using the Java API to do this function. However, the result is not very
satisfactory. The resized image quanlity is very bad.
Can anyone reccommend that any way or tool can resize image with good
quality?
Please help. My boss needs me to complete this project this week.
Regards,
Chris
- 5
- what i do wrong???Hello All!
I think I have a mistake in my logical sequence of thoughts...
When I want to take influence on my JComponents (JTextField,
JCheckBox, etc.),
do I have to place a listener within the constructor???
My problem was the following. I wanted to get the values from my
different JTextFields an write them to any *.txt file. That did only
work, when I inserted a KeyListener who registered any changes in the
text fields. But my real problem is now, to get the values back from
the *.txt file an set them with setText(String) in the text fields.
This don't work.
I have seen in the NG, that there will be oft spoken about
revalidate() or repaint(), but that don't work anyway.
It does not matter, what I want to do - set a component enabled, or
disabled or what ever, I have to have an adequate listener within the
constructor so that the changes will be visible, isn't it that way???
For example:
public void any_method()
{
myTextfield.setEnabled(false);
}
// IT DON'T WORK
// ...but I don't know why. When I put it within the constructor, it
works...
I don't know what to to. I know it from MFC, there I could get
influence on my components in any method.
I don't know what I do wrong in Java.
(My program is an application with JFrame and SWING componets. I use
JTabbedPane and for each tab a Jpanel)
There must be a simple solution for my problem (I hope so).
Please led me out from this dead-end street.
Thanks in advance
Dariusz
- 6
- How to receive events from a jcombobox in an internal Jpanel ??Good evening,
I've a Frame with two Jpanel, in Jpanel1 I've a Jcombobox and it's
listener while in Jpanel2 I've a JLabel where I want to write the
selected value of the Jcombobox,
Jpanel1 , Jpanel2 and the main frame are in 3 separate class and files,
this because I want to arrange a modular design.
My question is how I can receive in the main Frame the event coming
from Jcombox value changed in Jpanel1 ???
Thanks for your help
Antonio
www.etantonio.it/en
- 7
- Extending the code
I have the following code but i want to add a function which will allow
me to count the number of vowels in the text file. I was wondering if
anyone would be willing to give me some help with this
[CODE]
import java.io.*;
import java.util.*;
public class App {
//Create BufferedReader class instance
public static InputStreamReader input = new
InputStreamReader(System.in);
public static BufferedReader keyboardInput = new BufferedReader
(input);
public static void main(String[] args) {
int[] lengths = new int[100]; //Runtime error if the file contains a
word of more than 100 characters
int longestWord = 0;
for(int i = 0; i < lengths.length; i++) {
lengths[i] = 0;
}
try {
System.out.println("Enter the name of the file you wish to read:
");
String fileName = keyboardInput.readLine();
FileReader file = new FileReader(new File(fileName));
BufferedReader myFile = new BufferedReader(file);
int numTokens = 0;
int numWords = 0;
int numChar= 0;
String line;
while ((line = myFile.readLine()) != null ) {
String[] words = line.split(" ");
numWords = numWords + words.length;
for (int i = 0; i < words.length;i++) {
numChar = numChar + words[i].length();
if(words[i].length() > longestWord) {
longestWord = words[i].length();
}
lengths[words[i].length()] = lengths[words[i].length()] + 1;
}
}
System.out.println("\nThere are " + numWords + " words in the text
file");
System.out.println("\nThere are " + numChar + " characters in the
text file");
System.out.println("\nThere length frequency of the words is as
follows:");
System.out.println("\nLength : Frequency ");
for(int i = 0; i <= longestWord; i++) { //Print frequencies only up
to the longest word
System.out.println(i + " :"+lengths[i]);
}
myFile.close();
}
catch(IOException iO) {
iO.printStackTrace();
}
}
}
[/CODE]
- 8
- Error :could not initialize interface awt - Exception:java.lang.ExceptionInInitializerErrorHello
i had problems by the install of the german language pack 6.0.2.CF1
for a Lotus domino Server 6.0.2 CF1.
the System:
Acer altos 19000 Server
2X Pentium Pro 200 Mhz
512 MB Ram
OS windows 2000 Server SP4
the Update of the Notes Server was no Problem but when I tried to
install the Language Pack German (its an Java install Wizard ) there
coms the following Error Message :
Error :could not initialize interface awt - Exception:
java.lang.ExceptionInInitializerError
and if i installd the java software jre 1.3.1 standart the Aplet in
Systemcontrol could not be opend without anny Error Message.
what can I do?
Please help.
Thanks for Help
Stefan Germany
- 9
- Is Eclipse the Commercial IDE Killer?Thomas G. Marshall wrote:
> Super Spinner coughed up:
>> Tim Tyler wrote:
>>> In comp.lang.java.advocacy Super Spinner <email***@***.com>
>>> wrote or quoted:
>>>
>>> [Eclipse plugins]
>>>
>>>> I'd say that anyone that came up with an extension wouldn't be able
>>>> to make money because an OSS group would make a knock-off and give
>>>> it away for free.
>>>
>>> Your argument apparently suggests that nobody can make money selling
>>> software. I think history has proven that that is not the case.
>>
>> I think that one can make money by selling software only if the
>> software is "complex", where "complex" means "too complex to be
>> satisfactorily knocked off by OSS". And the set of "complex" sofware
>> becomes smaller and smaller, as OSS commodotizes more and more
>> markets. I used to think that something like Excel was sufficiently
>> complex to be safe from OSS, but I now know that within the next 5
>> years the spreadsheet market will be fully commodotized and therefore
>> not profitable. The same goes for all "office"-type apps. The same
>> goes for Photoshop and the like.
>>
>> The only software that I can see being safe from commodotization is
>> software that requires special domain knowledge, knowledge that devs
>> themselves do not possess and aren't likely to obtain in a competent
>> manner. Something like tax preparation software; this requires expert
>> knowledge of the tax laws and accountants that have such knowledge
>> aren't foolish enough to work for free like software devs appear to be
>> eager to do. So I can't see OSS "winning" in that space (yes, there
>> are OSS tax preparation packages, but the vast majority won't trust
>> that the devs understand the tax laws enough to trust those packages).
>>
>> Now, as for IDE extensions, sorry, there's no way that those are out
>> of the reach of OSS commodotization. Any extension would be knocked
>> off within a year, so the developers of the original would only have
>> one year to recoup the initial investment of resources and I don't see
>> anyone bothering to try. So nearly all future IDE extensions will
>> have to come from OSS from the get-go.
>>
>> A lot of OSS starts life as poor man's versions of commercial software
>> and gradually improves, but as commercial software is killed off, new
>> software inventions will have to come from OSS itself.
>>
>> As for individual programmers, they'll have to make money by working
>> on in-house stuff or custom solutions for a contractor, because it'll
>> be quite difficult to make money selling software to the general
>> public since OSS competition will make such an effort prohibitive.
>
> I have said for a lonnng time that if you write free software, you are
> only
> making it more difficult for other software engineers to earn a living. I
> don't mean small little utilities, like OE_QuoteFix and the like. But
> creating entirely free large scale applications doesn't make you a hero,
> it makes you a villain.
>
There's an easy solution to this. All the "for money" people have to do is
WRITE BETTER software...
I can't believe that projects like Eclipse are doing so well, simply because
they are OSS. It's because they are better...
--
******************************************************************************
Registered Linux User Number 185956
FSF Associate Member number 2340 since 05/20/2004
Join me in chat at #linux-users on irc.freenode.net
Buy an Xbox for $149.00, run linux on it and Microsoft loses $150.00!
7:42pm up 10 days, 4:15, 1 user, load average: 0.05, 0.07, 0.03
- 10
- show a form from anotherPlease bear with me as I am pretty new to Java.
I am developing a Java Client application.
I have a frame with a button. When I click on the button, it hides the
current frame and opens another frame which is in another class.
When I click on a button on this second frame, I want to close it
(this.dispose) and show the first frame.
The question I have is:
From the second class frame, how do I reference the first frame?
I don't want to close the first frame as I want to keep any data entered.
TS
- 11
- Any HID support for Java?Human Interface Device (mouse, etc)
Does anyone know whether java support the HID devices? (under MS
Windows)
I checked the document but did not see any. A google on this group
also returns little information.
Thanks a lot.
- 12
- Reference and Garbage CollectionI'm not quite sure about what kind of references to an object determine
its "alive" quality and its readiness for garbage collection. For the
moment I understand that *any* living reference, including non-explict
of member classes, keep the object alive.
Would you agree that the follwoing class "NeverRelease" entails
instances which will never get prone to garbage collection?
class NeverRelease
{
Child1 child;
public NeverRelease ()
{
child = new Child1();
}
private class Child1
{
}
}
While would you also agree that instances of the following class
"AlwaysRelease" always become garbage because the member class is static
and hence does not take reference to the enclosing class?
class AlwaysRelease
{
Child2 child;
public AlwaysRelease ()
{
child = new Child2();
}
private static class Child2
{
}
}
- 13
- src.zip of j2ee1.4 sdkHi,
I downloaded the j2ee1.4 sdk, but I can't seem to find the source files
in that package. They used to be in a src.zip file, or not? Anyway I
already looked at the Sun website, but I didn't find a URL to download
the source files from.
Kind regards,
Dirk
- 14
- Trusting ceritificates where CN does not match website hostnameJDK 1.4.2_08
I am getting the following exception:
javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: No trusted certificate found
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SunJSSE_ax.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA12275)
at
org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:224)
I have imported the certificate into the cacerts file via keytool -import.
However, my problem is that, the operator has setup a development and
production website, where the hostname naturally differs ... but both
development and production URLs have the same certificate.
That is, the production, Verisign-signed server certificate is the same
certificate on the development website. This ceritificate, therefore, has
the common-name ( CN ) set to the hostname of the production website.
Thus, even if I import the certificate into the cacerts file, because the
server certificate' CN does not match hostname of the website, I get the
exception above when connecting to their development website.
Apart from implementing DummyTrustManager as per this article:
http://www.javaworld.com/javatips/jw-javatip115.html
... which I'd rather not, is there any other workaround ??
- 15
- Creating HTML files from Java accessing OracleHello folks,
I have some queries that folks would like to have as HTML reports. At
first I tried Oracle Reports but it's HTML output seems really poor
and not 508 compliant which is an issue for us. I'd like to use JAVA
(I use Jdev as my IDE right now.) but was hoping someone might have
some insight on the best way to tackle this. I guess I am looking for
methods that would make things easier rather than just outputting
print commands line by line. :)
Thanks folks...
|
|
|