| How to ignore invalid SSL Certificates |
|
 |
Index ‹ java-programmer
|
- Previous
- 2
- overriding attributesI have a class A and a class B inheriting from A.
I have a class C and a class D inheriting from C.
I would like to have a attribute ATTR of type C in A. But in B, I would
ATTR to be of type D.
What should I do?
regards,
Andersen
- 3
- Best site for javahttp://javamobileweb.cogia.net
interactive site for java , mobile , wap and web .
a very helpful team also for all your question and problem
- 5
- IDE and good bookHi,
What is the best IDE for Java development:
1)eclipse 3.1
2)sun 1
3)jbuilder
4)gui's are for wusses use vi and a command line ant
What is a good book to learn java 1.4?
What is a good book to learn swing?
thanks in advance
- 6
- Java installationTry to install Java on my computer, but Microsoft tells me:
THE JAVA RUNTIME ENVIRONEMENT CANNOT BE LOADED FROM <bin\hotspot\jvm.dll
What am I doing wrong to install that applet
please reactions
Robert
- 6
- Leaf linked binary treeHi,
I need a LeafLinked Binary Tree for one of my current projejcts but I
can't find any. Does somebody know a good and performant implementation
I could use or do I have to code it myself?
Thanks,
Snyke
- 7
- 7
- 10
- Making the most of codeI have a web site that uses JSP and some back end classes to manage
data in a MySQL database. It does okay and has run well for about 3
years. It has, however, grown to the point where I need to redesign
some of it to be more dynamic. I've recently started incorporating
Hibernate and JavaServer Faces to ease the development now and make it
easier for me to make changes later on. Or at least that was my plan.
Each database table maps to a Java class. I will easily have 25-30
tables before I am done. I am okay with 25-30 classes to represent
the data, but my concern is when it comes to the associated classes
needed to manage the data connections and such. I find that I am
cutting and pasting way too much similar code into these separate
classes.
For example.
I have a HibernateDAO class that manages the Hibernate session.
Each class then has its own DAO class that extends the HibernateDAO
class and the code within the extended DAO classes is virtually
identical.
Here is one method from my clientDAO class.
public Client add( Client client) {
try {
begin();
getSession().save(client);
commit();
return get(client.getClientId()); //not every class
will have a clientId member
} catch (HibernateException e) {
rollback();
System.out.println( "Could not add client: " +
client.getClientId() + " : " + e); //message hard coded for client
class
return new Client();
}
}
And then in my ContactDAO class I have this.
public Contact add(Contact contact) {
try {
begin();
getSession().save(contact);
commit();
return get(contact.getId()); //not every class will have
an Id member
} catch (HibernateException e) {
rollback();
System.out.println( "Could not add contact: " +
contact.getId() + " : " + e); //Message hard-coded for contact class
return new Contact();
}
}
Note that the code is virtually identical.
The begin(), getSession(), rollback(), and commit() methods are all
from the HibernateDAO superclass.
I tried using Generics to make the return type and parameter <T>, but
this only gets me so far. I cannot declare a new instance of <T>, or
at least I don't know how to. And the method uses values that are
specific to the class in question. I.E. not every data class will
have a getId() method.
I am not sure if any of that made sense, but the crux of the issue is
I am trying to avoid cutting and pasting code and then having to
remember to update it in 25 different places when I make a change. I
feel like there is a way to do what I want, but I just don't have the
experience to see it.
If anyone can point me toward some documentation that might help set
me straight, I would appreciate it.
Thanks.
- 10
- HP Desktop for sale!Hi,
I have an unused HP Pavilion with the fallowing specs:
# Processor: AMD Athlon 64 X2 4000+ (2.1GHz, 2000MT/s System Bus)
# Memory: 2048MB PC2-5300 DDR2 SDRAM memory (2x1GB) (expandable to 8 GB (4 x 2 GB) (64-bit OS)/ 4 GB (4 x 1 GB) (32-bit OS))
# Hard Drive:320GB 7200RPM SATA 3G (3.0 Gb/sec) hard drive
# Optical Drive: 16X DVD(+/-)R/RW 12X RAM (+/-)R DL LightScribe SATA drive
# Expandable Drive Bay: HP Pocket Media Drive bay
# Video Graphics: Integrated graphics
# Network Interface: Integrated 10/100BaseT network interface
# Sound: High Definition 8-channel audio
# Fax/Modem: 56K bps data/fax modem
# Operating System: Genuine Windows Vista?Home Premium
This is "used" but basically brand new (it has literally been on for no more than 6 total hours..) is only 1 month old..
PRICE: $425 OBO
Email- email***@***.com
- 11
- Array Error
I'm getting two errrors with the simple code below:
For line 5 I get " <identifier> expected "
For line 6 I get " ']' expected" and also " <identifier> expected "
What gives?
Thanks
------------------------------------------
1 package com.dlm.testing;
2 import java.util.Arrays;
3 public class Test1 {
4 public String[] names;
5 names = new String[50];
6 names[0]="Jones";
7 }
- 13
- which data structure best fits this?hi,
i am looking for a data structure for fast retrievals... and here is my
scenario.
this table is about foreigncy exchange. i will have a buy currency,
sellcurrency, levels, and rate.
A transaction involves from a BUY currency to Sell currency, and it can
have multiple levels, meaning... if the sell amount is 1000, the rate
is 1.1, but if the sell amount is 2000, the rate is 1.2..etc...
Say there is a fixed amount of currencies that I need to maintain (say
10 type only) And I need to store all these rates in a structure, for
fast retrieval..
More concrete example.
Sell : USD Buy: EUR Level: 1 - 1000 rate: 1.1
Sell : USD Buy: EUR Level: 1000 - 5000 rate: 1.2
Sell : USD Buy: EUR Level: 5000 - 99999999 rate: 1.3
Sell : USD Buy: CAD Level: 1 - 1000 rate: 1.1
Sell : USD Buy: CAD Level: 1000 - 5000 rate: 1.2
Sell : USD Buy: CAD Level: 5000 - 99999999 rate: 1.3
Sell : USD Buy: GBP Level: 1 - 1000 rate: 1.1
Sell : USD Buy: GBP Level: 1000 - 5000 rate: 1.2
Sell : USD Buy: GBP Level: 5000 - 99999999 rate: 1.3
------ So, Sell for USD type is finished here.
Sell : EUR Buy: USD Level: 1 - 1000 rate: 1.1
Sell : EUR Buy: USD Level: 1000 - 5000 rate: 1.2
Sell : EUR Buy: USD Level: 5000 - 99999999 rate: 1.3
Sell : EUR Buy: CAD Level: 1 - 1000 rate: 1.1
Sell : EUR Buy: CAD Level: 1000 - 5000 rate: 1.2
Sell : EUR Buy: CAD Level: 5000 - 99999999 rate: 1.3
Sell : EUR Buy: GBP Level: 1 - 1000 rate: 1.1
Sell : EUR Buy: GBP Level: 1000 - 5000 rate: 1.2
Sell : EUR Buy: GBP Level: 5000 - 99999999 rate: 1.3
------ Sell for EUR is finished here.
so on with GBP, and CAD.
my requirements:
Say, someone tell me, what are all the rates for all the levels and
BuyType from EUR as sell?
Then that means I have to send back all the EUR as sell type.
Or, if someone say, what are all the rates for all the buytype for USD
from EUR as sell?
Then that means i have to send back all the EUR as sell, and USD for
Buy.
Or, if someone say, what are all the rates for all the buytype as GBP?
Then, i will have to send back all the buytype as GBP (including all
levels)
Or someone can just ask for a specific level as well for any buy type
of sell type, or both.
I was thinking about hash of hash... but if i have the Sell type as key
of the outer hash... then the inner hash will need to have a buytype as
the key... but then, i will have multiple levels...if i put the
multiple levels in an array of an object, and this object as the value
of this inner hash, that should be fine... but i am worry about the
speed.
Ideas?
thanks,
T
- 13
- Is heavy client dead? Is swing applet dead?Today most Java UI developers are focusing on solutions like Struts,
Taperstry, and JSF. It seems that noone care about Swing applet as a
choice as rich client.
Is heavy client dead? I think heavy client solution like swing applet
is still good for business application. Especially for many internal
business projects. In internal business environment, the download speed
is usually not a problem. Swing also provides better GUI than html.
Swing has the ability to cache information on the client side which
save a lot of network calls to server.
Do you agree? Should we all forget about Swing and heavy client
solution, and vote for Struts and JSF?
Thank you
Jim
- 13
- ""SEE THE BEST FRIENDS FOR YOUR SEX TALK""""SEE THE BEST FRIENDS FOR YOUR SEX TALK""
SEX TALK+SEX_JAFKJAJ;=SEXWORK
*********************************
http://www.freewebs.com/sociwok/
********************************
http://amigos.com/go/g903136-pmem
- 13
- It don't work with "PBEWithHmacSHA1AndDESede". What wrong?Hi.
In the following source, I got the exception :
"java.security.NoSuchAlgorithmException:
Cannot find any provider supporting PBEWithHmacSHA1AndDESede"
<source>
Cipher cipher;
SecretKey secretKey;
PBEParameterSpec parameterSpec;
try {
PBEKeySpec keySpec = new PBEKeySpec(password.toCharArray());
cipher = Cipher.getInstance("PBEWithHmacSHA1AndDESede");
SecretKeyFactory secKeyFac = SecretKeyFactory
.getInstance("PBEWithMD5AndDES");
secretKey = secKeyFac.generateSecret(keySpec);
parameterSpec = new PBEParameterSpec(salt, iteration);
} catch (NoSuchAlgorithmException e) {
} catch (NoSuchPaddingException e) {
} catch (InvalidKeySpecException e) {
}
</source>
The source above work with "PBEWithMD5AndDES". But, not
with "PBEWithHmacSHA1AndDESede". In the Sun's JCE API
Reference Guide, the "PBEWithHmacSHA1AndDESede" is the
standard name ( I use JDK 1.5 RC ).
What wrong? Thank you for your help.
- 15
- read from file in jspI'm develloping a site based on jsp.
In my javacode I want to read from a file located in the document root
of the web application. How do I do this when I dont know the name of
the host.
Should I consider locating the file somewhere else. It should actually
only be accessible from the code of the application.
Thanks for your help.
Nikolaj
|
| Author |
Message |
Snyke

|
Posted: 2006-3-6 5:48:00 |
Top |
java-programmer, How to ignore invalid SSL Certificates
Hi everybody :-)
I'm trying to build an application that serves as a Client Side
frontend for a webpage using HttpClient 2. Because I have some security
problems I decided that using https would be nice, but my SSL
certificates continue to fail validation and I'm wondering wether it is
possible to let HttpClient ignore Certification Failures? And if yes,
could you please give me a working example?
Greets,
|
| |
|
| |
 |
RenBeltman

|
Posted: 2006-3-6 5:57:00 |
Top |
java-programmer >> How to ignore invalid SSL Certificates
Hey Snyke,
In Mozilla you can check a certificate to accept it always, you can not
block those warnings (security issues in webbrowsers). In IE you can install
a base certificate (if this is accepted) to drop future warnings. This works
sepperate for every user in your network.
Greetings,
Ren?
"Snyke" <email***@***.com> wrote:
> Hi everybody :-)
>
> I'm trying to build an application that serves as a Client Side
> frontend for a webpage using HttpClient 2. Because I have some security
> problems I decided that using https would be nice, but my SSL
> certificates continue to fail validation and I'm wondering wether it is
> possible to let HttpClient ignore Certification Failures? And if yes,
> could you please give me a working example?
>
> Greets,
> --
> Christian 'Snyke' Decker http://www.Snyke.net
>
|
| |
|
| |
 |
Missaka Wijekoon

|
Posted: 2006-3-6 11:55:00 |
Top |
java-programmer >> How to ignore invalid SSL Certificates
Snyke wrote:
> Hi everybody :-)
>
> I'm trying to build an application that serves as a Client Side
> frontend for a webpage using HttpClient 2. Because I have some security
> problems I decided that using https would be nice, but my SSL
> certificates continue to fail validation and I'm wondering wether it is
> possible to let HttpClient ignore Certification Failures? And if yes,
> could you please give me a working example?
>
> Greets,
> --
> Christian 'Snyke' Decker http://www.Snyke.net
>
Snyke,
You need to import the fake SSL certificate authority into a key file.
Do that using the keytool (provided with Sun's JDK). Then in your java
program do the following before invoking any URL connections:
// Used to get the ssl certificates for https
System.setProperty
("javax.net.ssl.trustStore", "/path/to/keyfile");
System.setProperty
("javax.net.ssl.trustStorePassword", "YourPassword");
-Missaka
|
| |
|
| |
 |
Snyke

|
Posted: 2006-3-7 7:51:00 |
Top |
java-programmer >> How to ignore invalid SSL Certificates
Thank you Missaka,
I'll try that as soon as possible, have you a good resource on how to
do this, I'm pretty new to the SSL Stuff you know?
Greets,
|
| |
|
| |
 |
Snyke

|
Posted: 2006-3-8 7:36:00 |
Top |
java-programmer >> How to ignore invalid SSL Certificates
Ok so by now I was able to import the certificates into a
truststore.jks file using the following commands:
# wget
http://www.switch.ch/aai/federation/SWITCHaai/swisssignca.PEM.crt
# keytool -import -v -trustcacerts -alias swisssignca -file
./swisssignca.PEM.crt -keystore ./truststore.jks
And it seems to go alright because if I try to import the certificate
again it tells me that the certificate is already there.
I imported the same certificate into my browser and Firefox stopped
complaining about untrusted certificates at once, but I can't get the
code to work in Java. I used the code you posted above but it doesn't
seem to work...
Any ideas?
Thanks alot
|
| |
|
| |
 |
Snyke

|
Posted: 2006-3-8 7:52:00 |
Top |
java-programmer >> How to ignore invalid SSL Certificates
Now this is getting really dodgy:
when I run the stuff without the certificate import I get the following
error:
> sun.security.validator.ValidatorException: No trusted certificate found
which is absolutely fine for me as this is expected.
But when I run the code with my custom certificates I get the
following:
> sun.security.validator.ValidatorException: End user tried to act as a CA
which is what I don't like at all. What does this mean and how do I fix
it?
Thanks for your time,
|
| |
|
| |
 |
Roedy Green

|
Posted: 2006-3-8 8:03:00 |
Top |
java-programmer >> How to ignore invalid SSL Certificates
On 7 Mar 2006 15:36:11 -0800, "Snyke" <email***@***.com>
wrote, quoted or indirectly quoted someone who said :
>And it seems to go alright because if I try to import the certificate
>again it tells me that the certificate is already there.
>I imported the same certificate into my browser and Firefox stopped
>complaining about untrusted certificates at once, but I can't get the
>code to work in Java. I used the code you posted above but it doesn't
>seem to work...
>
>Any ideas?
see http://mindprod.com/jgloss/keyman.html
It is a gui equivalent of keytool that lets you see better what is
going on.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
Missaka Wijekoon

|
Posted: 2006-3-9 11:54:00 |
Top |
java-programmer >> How to ignore invalid SSL Certificates
Snyke wrote:
> Now this is getting really dodgy:
> when I run the stuff without the certificate import I get the following
> error:
>
>
>>sun.security.validator.ValidatorException: No trusted certificate found
>
>
> which is absolutely fine for me as this is expected.
> But when I run the code with my custom certificates I get the
> following:
>
>
>>sun.security.validator.ValidatorException: End user tried to act as a CA
>
>
> which is what I don't like at all. What does this mean and how do I fix
> it?
You might be importing the wrong certificate. The certificate authority
is used in generating the keys for the web server. That's the one you
would need to import.
-Missaka
|
| |
|
| |
 |
Snyke

|
Posted: 2006-3-12 8:13:00 |
Top |
java-programmer >> How to ignore invalid SSL Certificates
Mhz,
ok so far I tried all of the three certificates I got:
- SWITCH_CA.pem
- SWITCH_Personal.pem
- SWITCH_Server.pem
with server and personal it just tells me that there is no suitable
certificate found while for the CA I get the "End user tried to act as
CA"-Exception.
How do I know how the certificates depend on each other? Possibly I'd
like to know how to know from FireFox how to know which is the
certificate I imported.
Thanks,
Christian 'Snyke' Decker
http://www.Snyke.net
|
| |
|
| |
 |
Snyke

|
Posted: 2006-3-12 8:57:00 |
Top |
java-programmer >> How to ignore invalid SSL Certificates
This is definitely fishy:
As I understand it I have to accept a certificate that signed either
the certificate of the SSL connection or a parent of it (recursively),
or what?
Ok so as soon as I import a parent certificate into my truststore I get
the "End user tried to act as CA"-Error which is pretty annoying.
I tried to look at the certificates in Firefox and that's what came
out:
http://flickr.com/photos/snyke/111088778/
and if I import the SWITCH CA certificate
http://flickr.com/photos/snyke/111088777/
notice that the Serial Numbers are identical and when trying to import
the certificate again Firefox complains that the certificate already
exists.
What am I doing wrong???
javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: End user tried to act as a
CA
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.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(DashoA12275)
at
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:66)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:124)
at java.io.FilterOutputStream.flush(FilterOutputStream.java:123)
at
org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:502)
at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1973)
at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:395)
at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
at net.snyke.sms.Sender.login(Sender.java:67)
at net.snyke.sms.Sender.sendMessage(Sender.java:46)
at net.snyke.sms.testSender.testSendMessage(testSender.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: sun.security.validator.ValidatorException: End user tried to
act as a CA
at
sun.security.validator.SimpleValidator.checkBasicConstraints(SimpleValidator.java:239)
at
sun.security.validator.SimpleValidator.checkExtensions(SimpleValidator.java:158)
at
sun.security.validator.SimpleValidator.engineValidate(SimpleValidator.java:143)
at sun.security.validator.Validator.validate(Validator.java:202)
at
com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(DashoA12275)
at
com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(DashoA12275)
... 35 more
Thanks,
Christian 'Snyke' Decker
http://www.Snyke.net
|
| |
|
| |
 |
Snyke

|
Posted: 2006-3-28 6:13:00 |
Top |
java-programmer >> How to ignore invalid SSL Certificates
Man it can't be that hard to simply ignore those SSL-Certificates, can
it?
I'm still trying, but can't do anything...
Any idea?
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- 2
- Animation ProblemLew wrote:
> James Sarjeant wrote:
>> Thank you so much everyone, it worked with the javax.swing.Timer events.
>> Still got other bugs to iron out but thats a huge hurdle overcome.
>> Thanks again
>
> Remember: you think you have gotten away from the advice about the EDT,
> but you haven't.
>
It's a pesky thing isn't it :-).
--
Knute Johnson
email s/nospam/knute/
- 3
- Debugging API classes in NetbeansWhen Im debugging my program in Netbeans, and I try to debug into API
(e.g. Swing JPanel) the debugger tells me that the source of the class
has not been found in mounted filesystem. Even though
c:\j2sdk1.4.2_02\src.jar is indeed mounted.
How do I debug into API classes?
Thanxxxx,
Barsum
- 4
- Newbie question - reading delimited files and printing...Reading files - pipe delimited or comma delimeted...
Searching for a element in one field and then showing certain fields where
element is in line.
eg...
HEHE|HI|ME|2.5
JOKE|HELLO|YOU|3.4
DONT|HI|YOU|3.4
I want all rows with YOU in second column and I want to print out 2nd and
4th columns.
SO, my answer would be
HI 2.5
HI 3.4
...
Next question...
same list only a datestamp on the end...
HEHE|HI|ME|2.5|20031223091234
JOKE|HELLO|YOU|3.4|20031223091245
DONT|HI|YOU|3.4|20031223091247
....
1) I want all rows with YOU in second column and I want to print out 2nd and
4th columns in the 09:00:00 - 09:59:59 time frame.
2) I want an average of response time(4th field).
3) I want an average of response time broken down by hour.
Can someone help with all of this?
Please email to my home email (feel free to copy here).
email***@***.com
take out the _no_spam_
Thanks,
Markis
- 5
- Client application using Weblogic JMS ServerHello, I'm Jose from Barcelona,
I'm not at all expert on JMS, and my question is about how can I
connect a client application running java with a remote JMS Weblogic
Server. I've developed a client program and tested it with a Sun J2EE
server running on a XP box, but the goal is to make it run on an
iSeries machine connecting a WebLogic JMS Server.
My questions are:
Do I have to install some application software on the client box?
Is there any difference between connection with remote JMS servers and
connection with local ones?.
I hope you can help me.
Thank You.
- 6
- Serializable : readObject and writeObjectHello,
I have 3 classes Personne, entreeb==>FileInputStream ,
sortieb==>FileOutputStream.
The code works one time. The problem is when I add serialized new objects
( launch again the code sortieb) I can't read all objects (entreeb) specific
a new objects added.
have you an idea?
Thanks form help
-----------------------------------------------------------
-----------------------------------------------------------
//Class Personne
import java.io.*;
class Personne implements Serializable {
private String nom;
private int age;
public Personne(String n, int a){
nom = n;
age = a;
}
public void aff() {
System.out.println (nom + " " + age);
}
}
------------------------------------------------
//Flux in
import java.io.*;
import java.util.*;
public class entreeb {
public static void main(String[] args){
Personne p;
int i=0;
try {
FileInputStream fist= new FileInputStream("Personne.ser");
ObjectInputStream oist = new ObjectInputStream(fist);
try {
while (true)
{ System.out.println("i="+i);
p = (Personne) oist.readObject();
p.aff();
i++;
}
} catch (EOFException e) { }
oist.close();
} catch (Exception e) {
System.out.println("Exception loading personne : " + e.getMessage());
}
}
}
------------------------------------------------------------------
//Flux out
import java.io.*;
import java.util.*;
public class sortieb {
public static void main(String[] args) throws IOException {
Personne p = new Personne("name", 55);
File f=new File("Personne.ser");
FileOutputStream fost= new FileOutputStream(f,true);
ObjectOutputStream oost = new ObjectOutputStream(fost);
int i=0;
while (i<5) {
System.out.println("i = "+i+ "p="+p);
oost.writeObject(p);
i+=1;
}
oost.close();
}
}
- 7
- design problem: visitor/multiple dispatch or?Greetings and salutations,
I'm struggling with a bit of a mess (solely created by me and myself).
Suppose a bunch of types (classes) exist, say, T_1, T_2, ... T_n, implementing
a single interface or inheriting from some (abstract) base class T. Also assume
that some 'applicators' exit, say, A_1, A_2 ... Am, all implementing an interface
(or abstract base class) equivalent to --
interface Applicator {
Object apply(T ta, T tb);
}
If both sets T_i and A_j are 'fixed', i.e no new classes T_p nor A_q enter
my messy arena, I could implement all A_i as visitors to the T_j classes
in order to get their job done. OTOH, all T_j classes could double dispatch
the 'A_i.apply' methods to their T_j counterparts to get the job done.
I realise that some form of a Cartesian product of 'apply' methods must
reside somehwere, somehow ...
For the sake of the example, think of the T_j as being subclasses of classes
Short, Int, Long, Double, and let the Appliers be something like 'Add', 'Sub'
etc. i.e. the folllowing code snippet should make sense --
Add myAdd= new Add();
Dbl myDbl= new Dbl(41);
Int myInt= new Int(1);
// assume Num is a superclass of Dbl and Int
Num total= myAdd.apply(myDbl, myInt);
Variable 'total' should have type 'Dbl' in this example. As I wrote above,
there would be no problem if at least set T_j would be fixed; the visitor
pattern would do fine. If set A_i would be fixed the multiple dispatch
pattern (over the set T_j) would be a fine fit. But what to do if both sets
may be expanded?
I've fiddle-diddled with introspection, synthesizing class names given a T_i
and T_j, caching them in hashmaps but to no avail -- my code is a mess and
my design is something I'm ashamed off. I would really appreciate it if
some kind soul here could enlighten me.
TIA, and kind regards,
Jos
- 8
- truncating java doublesHi,
How do you truncate java doubles? I am trying to convert a double to a
number thats rounded to 3 decimal places - i can do this using BigDecimals
easily but cant seem to find anything to do the same with a double.
Thanks
- 9
- Telephonic CredentialsI think it would be nice if I could prove to someone on the other end
of the phone I am me, and demand they prove they are who they claim to
be.
It could be done by letting a modem kick in for a second to exchange
challenge phrases to be encrypted by identification certificate that
might include name, address, phone number, expiry date, company.
Then if some charity I donate to phone me, I can be sure it is them.
There are so many scams out there.
It might also be done by each of us contacting an Internet server.
Has anyone heard of such projects?
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
- 10
- Check for time functionHello all...I have an issue with one of my java script functions that
I'm hoping someone can easily help with. I have a web based application
that we use to create/sign up for overtime. When we have holidays we
require our employees to sign up in 4 hr increments for the times we
post. I'm having trouble creating a time slot that ends @ 12am. 12pm
and all other hours work fine for start/end times. however 12am causes
problems. My actual script code for this function is below. Someone
help!!!
<SCRIPT language="JavaScript" src="frmvalidation.js"
type="text/JavaScript"></SCRIPT>
<script language="javascript">
function checkValidHoliday(value)
{
if (value=='Y'){
hourblock.style.visibility ='visible';
}
else{
hourblock.style.visibility ='hidden';
}
}
function checkHoliday(frm)
{
if(frm.txtIsHoliday.value=="Y")
{
strFromDt= new Date(frm.txtLimitDate.value);
strToDt= new Date(frm.txtLimitToDate.value);
FromHr=parseInt(frm.txtLimitFrom.value);
FromAMPM=frm.txtLimitFromAM_PM.value;
ToHr=parseInt(frm.txtLimitTo.value);
ToAMPM=frm.txtLimitToAM_PM.value;
if((FromAMPM=="PM") && (FromHr!=12))
FromHr=FromHr+12;
if((ToAMPM=="PM") && (ToHr!=12))
ToHr=ToHr+12;
var fromDt= new
Date(strFromDt.getFullYear(),strFromDt.getMonth(),strFromDt.getDate(),FromHr,0);
var toDt= new
Date(strToDt.getFullYear(),strToDt.getMonth(),strToDt.getDate(),ToHr,0);
//alert(toDt + " " + fromDt);
//alert(FromHr + " " +ToHr);
var HolidayBlock=(parseInt(frm.cboHolidayHours.value) * 360 * 10000)
;
//alert((toDt-fromDt) + " " + HolidayBlock );
if((toDt-fromDt)== HolidayBlock)//14400000)
return true;
else
{
alert("Please select "+ parseInt(frm.cboHolidayHours.value) +" Hour
Block only for Holiday!");
frm.txtLimitFrom.focus();
return false;
}
}
return true;
}
</script>
- 11
- drag and drop in a JMenu/JMenuItem
Can someone please point me to some sample code that allows drag and
drop in a JMenu/JMenuItem. I know that Java doesn't support dnd in
the menu stuff, but I need it anyway. Technically speaking it doesn't
have to be a popup menu, but would be nice, as long as it has the look
and feel of a popup menu (i.e. fonts, size, etc.). An example of what
I'm talking about, via menus, is the start menu under Windows. Those
menus allow you to do dnd, but of course it's Windows and they allow
anything and everything. Just to note I'm using JDK 1.5.x if that
helps for the code direction.
- 12
- how to draw ER and UML diagram in eclipse?what free eclipse plugin do you use to draw database ER diagram and
UML diagrams?
I've tried omondo years ago, it leaks memory so bad back then and
always crash my eclipse, is it getting better now?
- 13
- Inidicator Arrow convention for Sort OrderWhich way should an arrow point to indicate an ascending sort or an
ascending list follows?
For an ascending sort the bigger numbers are at the bottom.
So no matter which way you do it, you can misinterpret.
Is there some other less ambiguous convetion to use?
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
- 14
- Java SoundI am intersted in building an applet that can both play and record
sound files. I would like this to work on the widest range of platforms
(MAC, Linux, WinXP, WinNT, etc) and browsers. What would be the best
file format for the sound files to accomplish this? Would it be MP3,
WAV, or what? I am looking to have this work without any added packages
over and above JDK 1.4.x.
Thanks for any and all info.
- 15
- Thoughts on Code reviewI need some advice guys.. I am proposing that we get someone to do a
complete audit/review of our Java application codebase, about 1000
JSPs/Servlets and 100 EJBs. If I get firms to submit proposals, what
should I be asking /looking out for? I realise that running the
applications through a migration tool will help but I am looking for a
more through analysis of the actual codebase as well as assessment of
the architecture
Thanks
Arvie
|
|
|