| Arrays.asList() doesn't work quite like I would think it should |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- a simple question realted to StringBufferHi,
I am using a StringBuffer to hold a line with fixed length of 72 chars.
Later, I am going to put char at a specified location, using
setCharAt(location, char) method.
But this code doesn't work:
<Java>
StringBuffer line = new StringBuffer(72);
line.setCharAt(5, 'A');
</Java>
This code works:
<Java>
StringBuffer line = new StringBuffer(72);
for (int i=0; i<72; i++) //make the StringBuffer contains 72 empty chars
{
line.append(' ');
}
line.setCharAt(5, 'A');
</Java>
I found that this required for loop is ridiculous. Reading the Java
document of StringBuffer suggests the first version is correct and
should work. I don't understand it.
Thank you very much for your help.
- 1
- Shift-click doesn't workG'day all
Just recently IE has done something - it wasn't me!!
When i shift-click now to open in a new window it doesn't work - the new
page will open but wo'nt load anything, it just gets stuck.
Any idea on how to fix it?
Cheers
B.
- 2
- Yet another error patternRoedy Green wrote
> The problem turned out is that there is a lot of repetitive
> gobblegegook you need to make Java GUIs work. The easiest way to
> generate it is to copy paste from where you did it before, and then
> change the variable name in half a dozen places.
>
> The catch is, if you forget one of the half-dozen places the code will
> compile, but do something strange.
>
> [...]
>
> How to avoid being bitten?
I have been bitten by this copy-paste error a few times too. I find that two
things work really well for me to avoid it:
- Define variables in as narrow scope as possible. For instance, I have
often found that most of my GUI elements only need to be referenced during
construction, not during normal operation when all the listeners are set up,
so most of my buttons, menus, lists, tables, etc, are defined as final
method variables, where different parts of the GUI is constructed in
different methods. In extreme cases (like in test code) I have even break
long methods into a list of scopes to ensure that variables are not "reused"
without initialization by accident.
- If I copy more than a one or two lines, I stop and think if perhaps it
would be better to refactor the otherwise copied code into a new method.
Regards,
--
Filip Larsen
- 2
- Arrow key functionality in the ButtonGroupHi All,
I added 4 JRadio buttons to ButtonGroup. For these radio buttons i am
unable to achieve the arrow key functionality. here i am attaching the
code
rateList = theController.getDeleteOptionList();
for (int i = 0, j = 1; i < rateList.size(); i++) {
ListElement listRb = (ListElement) rateList.get(i);
JRadioButton radioBtn = new JRadioButton(listRb.getTextValue());
radioBtn.setActionCommand(listRb.getTextValue());
radioBtn.addActionListener(actionclass);
deleteButtonGrp.add(radioBtn);
}
Thanks for ur help in advance...
Srinivas.
- 5
- Difference between 1.3 and 1.4 in JTable?Hi,
I wrote an application that uses a JTable to display some data. I wrote
my own cellrenderer that provides rows that contain multiple lines of text.
When a row is deleted all other rows are rerendered and the rowheight para-
meter is updated accordingly. This works in 1.3. But in 1.4 (I tried different
JDKs on different platforms (Linux/MacOSX/Windows..) the rowheights are not
updated. Is there a difference in the evaluation of this in 1.4? Maybe that
I have to change the rowheigth at a later point in the program?
Konstantin
--
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: email***@***.com
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not survive the forming of the cosmos." B'Elana Torres
- 6
- Start/Stop Threads Without Killing ThemThomas G. Marshall wrote:
> If what I was talking about was simply a tabs issue, then the tabs would
> go
> into notepad, then out of notepad and into OE and then get stripped out
> anyway. I'm talking about SPACE indents needing to be copied into
> notepad.
Ugh! Yes, how wretched.
I don't use space indentation myself so I hadn't realised it was /that/ broken.
> Sorry for confusing the issue. I would have sworn it was the same
> problem.
It probably is the same issue when you get right down to it -- YA3RWC, Yet
Another 3rd Rate Windows Control...
And now you've got me thinking about writing my own news reader again. And I
had other things to do today ;-)
-- chris
- 7
- Cannot start Eclipse on HPUX system - UI HangsHi,
I am trying to run Eclipse 3.1.1 on an HPUX machine (uname -a = B.
11.11, 9000/800 which I assume means I am running OS 11 on an HPUX
9000 machine) and I am using a 1.4 JVM. When I start Eclipse it hangs
on any window/wizard/dialog box that requires input. For example if I
start Eclipse with no parameters, the workspace window appears where I
choose my workspace directory. I cannot input any data or selct OK, or
anything. I am stuck there and need to kill everything.
If I run Eclipse with the -d option then it goes to the normal Eclipse
start window. Everything looks fine, but again I cannot select
anything, click on anything or use any menu. Also, the progress bar
that shows up while starting never quite finishes. There do not seem
to be any logs created that I can find.
I am running Cygwin from my laptop to connect to the remote HP Machine
and I am using ssh -Y to start the window/session.
Is there any trick to getting Eclipse to work on an HPUX machine?
Thanks
- 13
- Bug#476978: marked as done (default-jre: long description unfinished)This is a multi-part message in MIME format...
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
Your message dated Sat, 26 Apr 2008 22:17:02 +0000
with message-id <email***@***.com>
and subject line Bug#476978: fixed in java-common 0.30
has caused the Debian Bug report #476978,
regarding default-jre: long description unfinished
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact email***@***.com
immediately.)
--
476978: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=476978
Debian Bug Tracking System
Contact email***@***.com with problems
Received: (at submit) by bugs.debian.org; 20 Apr 2008 14:01:53 +0000
X-Spam-Checker-Version: SpamAssassin 3.1.4-bugs.debian.org_2005_01_02
(2006-07-26) on rietz.debian.org
X-Spam-Level:
X-Spam-Status: No, score=-9.9 required=4.0 tests=BAYES_00,FORGED_RCVD_HELO,
HAS_PACKAGE autolearn=no version=3.1.4-bugs.debian.org_2005_01_02
Return-path: <email***@***.com>
Received: from mail.biedermanns.net ([213.133.100.49] helo=mail.biedermann.info)
by rietz.debian.org with esmtp (Exim 4.63)
(envelope-from <email***@***.com>)
id 1Jna76-0008TR-Q6
for email***@***.com; Sun, 20 Apr 2008 14:01:53 +0000
Received: from chello084112034056.10.11.vie.surfer.at ([84.112.34.56] helo=edna.deb.at)
by mail.biedermann.info with esmtpsa
(Cipher TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63 #1 (Debian))
id 1Jna74-0001dP-37
for <email***@***.com>; Sun, 20 Apr 2008 16:01:51 +0200
Received: from rhonda by edna.deb.at with local (Exim 4.69)
(envelope-from <email***@***.com>)
id 1Jna7R-0006Pe-LV
for email***@***.com; Sun, 20 Apr 2008 16:02:13 +0200
Date: Sun, 20 Apr 2008 16:02:13 +0200
From: Gerfried Fuchs <email***@***.com>
To: Debian Bug Tracking System <email***@***.com>
Subject: default-jre: long description unfinished
Message-ID: <email***@***.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
X-Reportbug-Version: 3.39-0.1
User-Agent: Mutt/1.5.17+20080114 (2008-01-14)
Delivered-To: email***@***.com
Package: default-jre
Version: 1.5-29
Severity: minor
Hi!
#v+
Description: Standard Java or Java compatible Runtime
This package points to the Java runtime, or Java compatible
runtime recommended for the powerpc architecture,
which is java-gcj-compat-dev for .
#v-
I guess there is something missing before the final stop. :)
Rhonda
Received: (at 476978-close) by bugs.debian.org; 26 Apr 2008 22:31:37 +0000
X-Spam-Checker-Version: SpamAssassin 3.1.4-bugs.debian.org_2005_01_02
(2006-07-26) on rietz.debian.org
X-Spam-Level:
X-Spam-Status: No, score=-7.7 required=4.0 tests=BAYES_00,FVGT_m_MULTI_ODD,
HAS_BUG_NUMBER,HEADER_X_KATIE,IMPRONONCABLE_2,MURPHY_WRONG_WORD1,
MURPHY_WRONG_WORD2 autolearn=no
version=3.1.4-bugs.debian.org_2005_01_02
Return-path: <email***@***.com>
Received: from ries.debian.org ([128.148.34.103])
by rietz.debian.org with esmtp (Exim 4.63)
(envelope-from <email***@***.com>)
id 1Jpsvh-0005jT-Ds
for email***@***.com; Sat, 26 Apr 2008 22:31:37 +0000
Received: from dak by ries.debian.org with local (Exim 4.63)
(envelope-from <email***@***.com>)
id 1Jpsha-0000pq-Pt; Sat, 26 Apr 2008 22:17:02 +0000
From: Michael Koch <email***@***.com>
To: email***@***.com
X-DAK: dak process-unchecked
X-Katie: $Revision: 1.65 $
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Subject: Bug#476978: fixed in java-common 0.30
Message-Id: <email***@***.com>
Sender: Archive Administrator <email***@***.com>
Date: Sat, 26 Apr 2008 22:17:02 +0000
Source: java-common
Source-Version: 0.30
We believe that the bug you reported is fixed in the latest version of
java-common, which is due to be installed in the Debian FTP archive:
default-jdk-builddep_1.5-30_amd64.deb
to pool/main/j/java-common/default-jdk-builddep_1.5-30_amd64.deb
default-jdk_1.5-30_amd64.deb
to pool/main/j/java-common/default-jdk_1.5-30_amd64.deb
default-jre-headless_1.5-30_amd64.deb
to pool/main/j/java-common/default-jre-headless_1.5-30_amd64.deb
default-jre_1.5-30_amd64.deb
to pool/main/j/java-common/default-jre_1.5-30_amd64.deb
java-common_0.30.dsc
to pool/main/j/java-common/java-common_0.30.dsc
java-common_0.30.tar.gz
to pool/main/j/java-common/java-common_0.30.tar.gz
java-common_0.30_all.deb
to pool/main/j/java-common/java-common_0.30_all.deb
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to email***@***.com,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Michael Koch <email***@***.com> (supplier of updated java-common package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing email***@***.com)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Format: 1.8
Date: Sun, 27 Apr 2008 00:13:55 +0200
Source: java-common
Binary: java-common default-jre default-jre-headless default-jdk default-jdk-builddep
Architecture: source all amd64
Version: 0.30
Distribution: unstable
Urgency: low
Maintainer: Debian Java Mailing List <email***@***.com>
Changed-By: Michael Koch <email***@***.com>
Description:
default-jdk - Standard Java or Java compatible Development Kit
default-jdk-builddep - Standard Java or Java compatible build dependencies
default-jre - Standard Java or Java compatible Runtime
default-jre-headless - Standard Java or Java compatible Runtime (headless)
java-common - Base of all Java packages
Closes: 476978
Changes:
java-common (0.30) unstable; urgency=low
.
* Fix description generation for default-jre. Closes: #476978.
Checksums-Sha1:
5041e6f847455fa7f4e562f8d30913d9a1b66a10 1022 java-common_0.30.dsc
86dd75060a98ff5450a8eea5450c9290b57a2c48 66845 java-common_0.30.tar.gz
1855b7ca6ea99d03d01f9ce455b046d1b83ae50a 77022 java-common_0.30_all.deb
38200498bf10fc39c35d52d91e78077dc311d6cc 1034 default-jre_1.5-30_amd64.deb
f0563383f80aa063fea43010ee1c4c6b07e2ad3c 5568 default-jre-headless_1.5-30_amd64.deb
9fe0b0f9a0b90b7209c304b51126d3168be2b9ce 1030 default-jdk_1.5-30_amd64.deb
b3c52196e45a6f2551925ba5fe0f6349081e6e98 984 default-jdk-builddep_1.5-30_amd64.deb
Checksums-Sha256:
4f3dd377ea00d049d02dfd3f5accde7ce3dfda13d6127a76364c601dd6c9254b 1022 java-common_0.30.dsc
9ac642626c5631a9f883440862b4aa3a8b7288dcb21ae6bb63fbde5ead3a3546 66845 java-common_0.30.tar.gz
600554190a9c05d2f2b93b803eb146627208edb6acf8030f0cde3cb10a9e2bc0 77022 java-common_0.30_all.deb
53044965f85e51f762d03e2f9cdbfd919b9e619030e761258c13b5452b08bf34 1034 default-jre_1.5-30_amd64.deb
c26d792bef37535f12165880a60ef7dbaa00f57d78148d028bb26ce6b7f50738 5568 default-jre-headless_1.5-30_amd64.deb
f0e51ce63685ee14aaf716d2c1c0882f1e84cf11985522504e5b71460ffaa525 1030 default-jdk_1.5-30_amd64.deb
d243edd83651a97ea819043db83a4a115933bd378a9b636521fe0b656912e296 984 default-jdk-builddep_1.5-30_amd64.deb
Files:
b682cd43f6d7ca8abafa585aab5ddd08 1022 misc optional java-common_0.30.dsc
7c963d75a24b2eabf11b35f7f93e1120 66845 misc optional java-common_0.30.tar.gz
4b2f240539a66dde0b0e887364ad0d32 77022 misc optional java-common_0.30_all.deb
242e2f95fedff420a458ba488819cce0 1034 interpreters optional default-jre_1.5-30_amd64.deb
e9a57f3a6b29884c9d5de3eadf650cfd 5568 interpreters optional default-jre-headless_1.5-30_amd64.deb
ddfb196b43e2b388a16d5001bfad3857 1030 devel optional default-jdk_1.5-30_amd64.deb
67604df5ffdc994c5b688a0f41143575 984 devel optional default-jdk-builddep_1.5-30_amd64.deb
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFIE6nkWSOgCCdjSDsRAgtfAKCXqb9P9pKdYaqFNC+14rOM/peFngCfflI6
1XdeIAPvVGcyTCwU/KxQWSc=
=2SAN
-----END PGP SIGNATURE-----
- 13
- custom jtable copy command?Hi.
I am trying to implement a custom behavior on the copy command on
jtable.
Basically I force the entire row to be selected when a user is working
with myJtable. I feel this is a good design because it allows the user
to quickly see what they are working with, without a doubt.
However I would like to customize the copy command on the jtable
because some of the items in the row are images, which I would not like
to allow the user to copy (it gets converted into text, and it looks
ugly!).
What I would like to do is have the copy command ignore the columns
with the images in them, and only copy the textual columns. Im not
sure how to go about doing this, does anyone have any insight for me?
Thanks!
- 15
- JList/MouseListenerHi all
I'm using two JLists with the same MouseListener in a JFrame. How can I find
out on which JList the MouseEvent was released?
Is it generally possible or should I use a MouseListener for each JList?
Thanx for your help
Roman
- 15
- Problem about JavaMailHi,
I'm just trying to use JavaMail and have a strange problem.
(See the code snippet below)
When running it, the exception error message is:
errorjavax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: Could not connect to SMTP host: localhost,
port: 25;
nested exception is:
java.net.ConnectException: Connection refused
the problem is in the line with //!!!!
If I comment this line out, it works fine.
The purpose of this line to invoke check_server is to
have a check first.
Who can give me some hints?
Thanks much!
================================================
import java.sql.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
/** Class handles sending email messages. */
public class email {
private static String mail_host = null;
public static void main (String[] args) {
mail_host = "mrby.8866.org"; //which is a valid mail server
if ( check_server(mail_host) ) //!!!!!
send();
}
public static void send ()
{
String to = "root@localhost";
String subject = "hello,world";
String total_message = "test email";
String from = "email***@***.com";
String host = mail_host;
Properties props = new Properties();
props.put("mail.smtp.host", host );
Session session = Session.getDefaultInstance(props, null);
try {
// create a message
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipients( Message.RecipientType.TO,
InternetAddress.parse(to) );
msg.setSubject(subject);
msg.setText(total_message);
Transport.send(msg);
System.out.println(host);
}
catch (MessagingException mex) {
System.out.println("error"+mex.toString());
}
}
// Method to check if the SMTP service on a host is available
private static boolean check_server( String host )
{
boolean flag;
Transport tr = null;
try {
Properties props = new Properties();
Session session = Session.getDefaultInstance(props,null);
tr = session.getTransport("smtp");
tr.connect(host,null,null);
flag = true;
tr.close();
}
catch (MessagingException mx) {
flag = false;
}
finally {
try {
if (tr != null) {
tr.close();
}
}
catch (MessagingException mex) {}
}
return flag;
}
}
- 15
- Java Axis2 Client Calling .NET 2.0 Web Service..I am able to get the call to the .net 2.0 web service with this code:
[code]
InventoryServicesStub stub = new InventoryServicesStub(null,
"http://localhost:2067/NGLPTOServices_VS/InventoryServices.asmx/Ping");
InventoryServicesStub.Ping ping = new InventoryServicesStub.Ping();
InventoryServicesStub.PingResponse response = stub.Ping(ping);
String results = response.getPingResult();
System.out.println("Response : " + results);
[/code]
I can see it execute in Visual Studio debugger and return. When control
comes back to my eclipse debugger, I get the following AxisFault:
"First Element must contain the local name, Envelope"
How do I fix this?
Here is my WSDL:
[code]
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://tempuri.org/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="http://tempuri.org/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified"
targetNamespace="http://tempuri.org/">
<s:element name="Ping">
<s:complexType />
</s:element>
<s:element name="PingResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="PingResult"
type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetInventoryReport">
<s:complexType />
</s:element>
<s:element name="GetInventoryReportResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1"
name="GetInventoryReportResult" type="tns:Results" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="Results">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="timestamp"
type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="status"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="message"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="report"
type="tns:ArrayOfInventoryReport" />
</s:sequence>
</s:complexType>
<s:complexType name="ArrayOfInventoryReport">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded"
name="InventoryReport" nillable="true" type="tns:InventoryReport" />
</s:sequence>
</s:complexType>
<s:complexType name="InventoryReport">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="CONTRACT"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PRODUCT_NAME"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="VOLUME_TYPE"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="MV_HEADER_DATE"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="TICKET"
type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="BARRELS"
type="s:double" />
<s:element minOccurs="1" maxOccurs="1" name="PRODUCT_ORDER"
type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="SORT_ORDER"
type="s:int" />
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="PingSoapIn">
<wsdl:part name="parameters" element="tns:Ping" />
</wsdl:message>
<wsdl:message name="PingSoapOut">
<wsdl:part name="parameters" element="tns:PingResponse" />
</wsdl:message>
<wsdl:message name="GetInventoryReportSoapIn">
<wsdl:part name="parameters" element="tns:GetInventoryReport" />
</wsdl:message>
<wsdl:message name="GetInventoryReportSoapOut">
<wsdl:part name="parameters"
element="tns:GetInventoryReportResponse" />
</wsdl:message>
<wsdl:portType name="InventoryServicesSoap">
<wsdl:operation name="Ping">
<wsdl:input message="tns:PingSoapIn" />
<wsdl:output message="tns:PingSoapOut" />
</wsdl:operation>
<wsdl:operation name="GetInventoryReport">
<wsdl:input message="tns:GetInventoryReportSoapIn" />
<wsdl:output message="tns:GetInventoryReportSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="InventoryServicesSoap"
type="tns:InventoryServicesSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Ping">
<soap:operation soapAction="http://tempuri.org/Ping"
style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetInventoryReport">
<soap:operation
soapAction="http://tempuri.org/GetInventoryReport" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="InventoryServicesSoap12"
type="tns:InventoryServicesSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Ping">
<soap12:operation soapAction="http://tempuri.org/Ping"
style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetInventoryReport">
<soap12:operation
soapAction="http://tempuri.org/GetInventoryReport" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="InventoryServices">
<wsdl:port name="InventoryServicesSoap"
binding="tns:InventoryServicesSoap">
<soap:address
location="http://localhost:2067/NGLPTOServices_VS/InventoryServices.asmx"
/>
</wsdl:port>
<wsdl:port name="InventoryServicesSoap12"
binding="tns:InventoryServicesSoap12">
<soap12:address
location="http://localhost:2067/NGLPTOServices_VS/InventoryServices.asmx"
/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
[/code]
- 15
- Oracle TopLink + composite mappingHello,
I have a little problem with Toplink:
I have a table in Oracle DB:
table T1 {A: integer, B: integer, C: integer}.
I want to have following mapping:
class X { int A; intB;}
class Y{ X objct; int C}
so the objct (of class X) is a composite of class Y, and both of
objects (composite and owner) are in the same table.
Is it possible to make such a mapping in TopLink?
Thanks for every helpful answer.
- 16
- XML QuestionsI have a very simple XML document for settings in an program I have written.
I want to be able to read in and update these settings.
- Would I be better using DOM or SAX?
- What would be the best parser for me?
Also, as I'm new to XML in Java (and also fairly new to Java) I'm still
unsure on what effect exactly implementing XML in my program will have. It's
a very simple program (the java files are 35kb in total) - it appears to me
that if I use XML then I'll have to include a comparatively huge XML parser
with my program when distributing it - I've just downloaded the IBM one and
it's 2.6MB. Is this true or am I misunderstanding something fundamental
here?
TIA.
- 16
- FreeBsdCrypt updatedAlas, I don't have the time to make a proper port of this (but if someone
else wants to, please do feel free) but since there's an update and folks
may find this useful, I thought I'd mention it anyway.
FreeBsdCrypt can be found at
http://spatula.net/software/FreeBsdCrypt-1.1.jar . This contains an
implementation of FreeBSD-style MD5 crypt, which many have found useful
when trying to integrate Java stuff with FreeBSD stuff, or migrating from
other languages to servlets, or whatever.
The jar contains all the API docs, source code, and the complied class.
Usage is pretty simple anyway:
String result = FreeBsdCrypt.crypt("password", "salt");
The major change in this version is correcting the way the class name is
capitalized. It needed to start with an uppercase letter since it's a
class name, and then Pascal-casing the rest of it. Consensus on the web
seems to be that acronyms of 3 letters or more are to be Pascal-cased.
Nick
--
"The aptly-named morons.org is an obscenity-laced screed..."
-- Robert P. Lockwood, Catholic League director of research
Nick Johnson, version 2.1 http://web.morons.org/
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
|
| Author |
Message |
Ken

|
Posted: 2007-10-3 11:25:00 |
Top |
java-programmer, Arrays.asList() doesn't work quite like I would think it should
I've included an example of the problem I've run into. I'm trying to
randomize an array of integers, much like the following program does.
Unfortunately when I ask the system to do so, I don't get a randomized
array. Now normally this wouldn't bother me. I would just assume that
a new object is being created and then destroyed by the garbage collector
without my ever seeing it, but in this case it looks like a bug.
Isn't the whole point of the asList() interface to allow this kind of
thing?
Is this a bug in Java?
--
Kenneth P. Turvey <email***@***.com>
--------------------------------------------------------------------
import java.util.Arrays;
import java.util.Collections;
public class ArrayAsListTester {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int indicies[] = new int[100];
for (int index = 0; index < 100; index++) {
indicies[index] = index;
}
Collections.shuffle(Arrays.asList(indicies));
for (int index = 0; index < 100; index++) {
System.out.println(indicies[index]);
}
}
}
|
| |
|
| |
 |
ram

|
Posted: 2007-10-3 12:09:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
Ken <email***@***.com> writes:
>--
Writing your program in front of the signature separator
will enhance the visibility of your code.
>int indicies[] = new int[100];
Use 籮ava.lang.Integer indicies[] = new java.lang.Integer[ 100 ];?here.
Otherwise, 籥sList?will see an array with only one component
籭ndicies?because its parameter has type 籘...?
Using an English word like 籭ndices?(instead of
籭ndicies? will enhance the readability of your code.
|
| |
|
| |
 |
xen

|
Posted: 2007-10-3 12:11:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
On 03 Oct 2007 03:24:42 GMT, Ken <email***@***.com> wrote:
>I've included an example of the problem I've run into. I'm trying to
>randomize an array of integers, much like the following program does.
>Unfortunately when I ask the system to do so, I don't get a randomized
>array. Now normally this wouldn't bother me. I would just assume that
>a new object is being created and then destroyed by the garbage collector
>without my ever seeing it, but in this case it looks like a bug.
>
>Isn't the whole point of the asList() interface to allow this kind of
>thing?
>
>Is this a bug in Java?
Arrays.asList() tries to instantiate an ArrayList on the specified
array but an ArrayList can never be backed by an int[].
If you call asList() on an int[], you will get a List<int[]> with one
element: the int[] you supplied. If you call shuffle on that list,
nothing will change in the int[].
You don't get an error because the parameter for asList is a "T... a".
If you call it with a T[], that array is passed.
If you call it with an array of a primitive type, then it cannot be
treated as a T[] because generic types cannot be primitives. Instead,
because int[] itself is an object, it matches the T in the signature
and is wrapped inside an array. So what actually gets passed is not
your int[], but an array of int[] with one element.
There is no way for the compiler to generate an error.
And why should ArrayList(T... t) complain? An int[] is a valid type
parameter.
Perhaps the compiler should generate a warning if you pass an array of
primitive to a generic dynamic array parameter.
Anyway, you can only solve it by using an Integer[] instead of an
int[].
|
| |
|
| |
 |
Mark Space

|
Posted: 2007-10-3 12:17:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
Ken wrote:
> I've included an example of the problem I've run into. I'm trying to
> randomize an array of integers, much like the following program does.
> Unfortunately when I ask the system to do so, I don't get a randomized
> array. Now normally this wouldn't bother me. I would just assume that
> a new object is being created and then destroyed by the garbage collector
> without my ever seeing it, but in this case it looks like a bug.
>
> Isn't the whole point of the asList() interface to allow this kind of
> thing?
>
> Is this a bug in Java?
>
I doubt it. A more experienced Java programmer would spot this right away.
I didn't run your program (which is a shame since you did include a good
one), but I'm gonna guess that the output is a sorted, not randomized list.
Not a Java bug.
asList returns a NEW OBJECT. Your original array was never touched. Try
something like:
List myList = Arrays.asList(indicess);
Collections.shuffle(myList);
Then print out myList and see what you get.
|
| |
|
| |
 |
ram

|
Posted: 2007-10-3 12:31:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
Mark Space <email***@***.com> writes:
>asList returns a NEW OBJECT. Your original array was never touched.
In German, there is a saying 籛er schreit hat Unrecht.. Thus,
籆hanges to the returned list "write through" to the array.?
http://download.java.net/jdk7/docs/api/java/util/Arrays.html#asList(T...)
1) 籋e who shouts is wrong.? In Usenet, using
all caps sometimes is considered to resemble shouting.
|
| |
|
| |
 |
Roedy Green

|
Posted: 2007-10-3 13:40:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
On 03 Oct 2007 03:24:42 GMT, Ken <email***@***.com> wrote, quoted or
indirectly quoted someone who said :
> Collections.shuffle(Arrays.asList(indicies));
asList makes a copy. So you have shuffled a new copy of the data in a
List then thrown it away. Your code does not shuffle the original
array.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
Daniel Pitts

|
Posted: 2007-10-3 13:42:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
Roedy Green wrote:
> On 03 Oct 2007 03:24:42 GMT, Ken <email***@***.com> wrote, quoted or
> indirectly quoted someone who said :
>
>> Collections.shuffle(Arrays.asList(indicies));
>
> asList makes a copy. So you have shuffled a new copy of the data in a
> List then thrown it away. Your code does not shuffle the original
> array.
>
>
Actually, it does *not* make a copy. It makes a List instance that
"wraps" the array.
The problem with the OP's code is the fact that you can't use
Arrays.asList on an array of primatives.
Many people have pointed this out, and have suggested that the OP use
Integer[] instead. It is a pity that Sun didn't add an Arrays.shuffle
for the primitive array types.
|
| |
|
| |
 |
Roedy Green

|
Posted: 2007-10-3 13:46:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
On 3 Oct 2007 04:30:51 GMT, email***@***.com (Stefan Ram) wrote,
quoted or indirectly quoted someone who said :
> 籆hanges to the returned list "write through" to the array.?
That was a surprise. I looked up Arrays.asList and there it was.
It also says .
This method also provides a convenient way to create a fixed-size list
initialized to contain several elements.
This means insert and delete would be suppressed. Shuffle just might
try to use those methods.
I got caught because I always use these idioms:
ArrayList <=> array
// NEW STYLE with generics
// converting an array to an ArrayList, with Generics
String[] animals = { "bear", "cougar", "wolverine"};
ArrayList<String> al = new ArrayList<String>( Arrays.asList( animals )
);
// converting an ArrayList to an array with generics.
String[] predators = al.toArray( new String[ al.size() ] );
// OLD STYLE, without generics
// converting an array to an ArrayList, without Generics
String[] animals = { "bear", "cougar", "wolverine"};
ArrayList al = new ArrayList( Arrays.asList( animals ) );
// converting an ArrayList to an array without generics,
String[] predators = (String[])al.toArray( new String[ al.size() ] );
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
Piotr Kobzda

|
Posted: 2007-10-3 15:24:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
Daniel Pitts wrote:
> It is a pity that Sun didn't add an Arrays.shuffle
> for the primitive array types.
Maybe lack of boxing of primitive type arrays is bigger pity?
Hopefully, we can easily do something similar, see example below.
piotr
import java.util.*;
public class ArrayBoxingTest {
public static void main(String[] args) {
final int[] a = new int[] { 1, 2, 3, 4, 5 };
Collections.shuffle(new AbstractList<Integer>() {
public int size() { return a.length; }
public Integer get(int index) { return a[index]; }
public Integer set(int index, Integer element) {
Integer r = a[index];
a[index] = element;
return r;
}
});
System.out.println(Arrays.toString(a));
}
}
|
| |
|
| |
 |
Roedy Green

|
Posted: 2007-10-3 15:49:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
On 03 Oct 2007 03:24:42 GMT, Ken <email***@***.com> wrote, quoted or
indirectly quoted someone who said :
> Collections.shuffle(Arrays.asList(indicies));
This code puzzled the heck out of me.
I have done experiments and I think I now know what is going on. It
is far stranger than you would imagine.
I have posted my findings at
http://mindprod.com/jgloss/array.html#GOTCHAS
I think it fair to say OP DID find a bug in Java, or at least the
mother of all gotchas.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
Roedy Green

|
Posted: 2007-10-3 15:55:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
On Tue, 02 Oct 2007 22:42:24 -0700, Daniel Pitts
<email***@***.com> wrote, quoted or indirectly
quoted someone who said :
>The problem with the OP's code is the fact that you can't use
>Arrays.asList on an array of primatives.
>
>Many people have pointed this out, and have suggested that the OP use
>Integer[] instead. It is a pity that Sun didn't add an Arrays.shuffle
>for the primitive array types.
But you don't get any error message, just some VERY weird run-time
behaviour. see http://mindprod.com/jgloss/array.html#GOTCHAS
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
Ken

|
Posted: 2007-10-3 16:19:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
On Wed, 03 Oct 2007 07:49:23 +0000, Roedy Green wrote:
> On 03 Oct 2007 03:24:42 GMT, Ken <email***@***.com> wrote, quoted or
> indirectly quoted someone who said :
>
>> Collections.shuffle(Arrays.asList(indicies));
>
> This code puzzled the heck out of me.
It did me too. Thank all of you for your assistance in this matter. I
understand the problem now. I'm still a bit annoyed that there isn't a
straight forward way to shuffle an array of ints given that the code is
already there hidden somewhere, but at least I understand the problem now.
--
Kenneth P. Turvey <email***@***.com>
|
| |
|
| |
 |
Roedy Green

|
Posted: 2007-10-3 20:30:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
On 03 Oct 2007 08:18:50 GMT, Ken <email***@***.com> wrote, quoted or
indirectly quoted someone who said :
>It did me too. Thank all of you for your assistance in this matter. I
>understand the problem now. I'm still a bit annoyed that there isn't a
>straight forward way to shuffle an array of ints given that the code is
>already there hidden somewhere, but at least I understand the problem now.
Let's peek under the covers at java.util.Collections.shuffle.
Internally it converts to an array to shuffle!
/**
* Randomly permute the specified list using the specified source
of
* randomness. All permutations occur with equal likelihood
* assuming that the source of randomness is fair.<p>
*
* This implementation traverses the list backwards, from the last
element
* up to the second, repeatedly swapping a randomly selected
element into
* the "current position". Elements are randomly selected from
the
* portion of the list that runs from the first element to the
current
* position, inclusive.<p>
*
* This method runs in linear time. If the specified list does
not
* implement the {@link RandomAccess} interface and is large, this
* implementation dumps the specified list into an array before
shuffling
* it, and dumps the shuffled array back into the list. This
avoids the
* quadratic behavior that would result from shuffling a
"sequential
* access" list in place.
*
* @param list the list to be shuffled.
* @param rnd the source of randomness to use to shuffle the
list.
* @throws UnsupportedOperationException if the specified list or
its
* list-iterator does not support the <tt>set</tt>
operation.
*/
public static void shuffle(List<?> list, Random rnd) {
int size = list.size();
if (size < SHUFFLE_THRESHOLD || list instanceof RandomAccess)
{
for (int i=size; i>1; i--)
swap(list, i-1, rnd.nextInt(i));
} else {
Object arr[] = list.toArray();
// Shuffle array
for (int i=size; i>1; i--)
swap(arr, i-1, rnd.nextInt(i));
// Dump array back into list
ListIterator it = list.listIterator();
for (int i=0; i<arr.length; i++) {
it.next();
it.set(arr[i]);
}
}
}
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
Roedy Green

|
Posted: 2007-10-3 20:56:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
On Wed, 03 Oct 2007 12:29:52 GMT, Roedy Green
<email***@***.com> wrote, quoted or indirectly quoted
someone who said :
>
>Let's peek under the covers at java.util.Collections.shuffle.
>Internally it converts to an array to shuffle!
Here is the guts, that handles an int[]. Note how much simpler the
code is. You can download this as part of the common11 package
at http://mindprod.com/products.html#COMMON11
/**
* Shuffles an int[], much like Collections.shuffle
* copyright (c) 2007 Roedy Green, Canadian Mind Products Shareware
that may be copied and used freely for any purpose but military.
Roedy Green<
Canadian Mind Products
#101 - 2536 Wark Street
Victoria, BC Canada
V8T 4G8
mailto:email***@***.com
http://mindprod.com
*/
package com.mindprod.common11;
import java.util.Random;
/**
* Shuffles an int[], much like Collections.shuffle
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0, 2007-10-03 Created with IntelliJ IDEA.
*/
public class Shuffle {
// ------------------------------ FIELDS
------------------------------
/**
* true if you want the debugging main harness.
*/
private static final boolean DEBUGGING = true;
/**
* default source of randomness for shuffling.
*/
private static Random wheel;
// -------------------------- PUBLIC STATIC METHODS
--------------------------
/**
* Works much like Collections.shuffle. Randomly permutes the
specified list
* using a default source of randomness. All permutations occur
with
* approximately equal likelihood.<p>
* <p/>
* The hedge "approximately" is used in the foregoing description
because
* default source of randomness is only approximately an unbiased
source of
* independently chosen bits. If it were a perfect source of
randomly chosen
* bits, then the algorithm would choose permutations with perfect
* uniformity.<p>
* <p/>
* This implementation traverses the list backwards, from the last
element
* up to the second, repeatedly swapping a randomly selected
element into
* the "current position". Elements are randomly selected from
the portion
* of the list that runs from the first element to the current
position,
* inclusive.<p>
*
* @param toShuffle the array to be shuffled.
*/
public static void shuffle( int[] toShuffle )
{
// wheel is initialised only once, and only if needed.
if ( wheel == null )
{
wheel = new Random();
}
shuffle( toShuffle, wheel );
}
/**
* This method uses the same technique as Collections.shuffle, but
is
* somewhat simpler with direct array access. Randomly permute the
specified
* list using the specified source of randomness. All
permutations occur
* with equal likelihood assuming that the source of randomness is
fair.<p>
* <p/>
* This implementation traverses the array backwards, from the
last element
* up to the second, repeatedly swapping a randomly selected
element into
* the "current position". Elements are randomly selected from
the portion
* of the list that runs from the first element to the current
position,
* inclusive.<p>
*
* @param toShuffle the array to be shuffled.
* @param wheel the source of randomness to use to shuffle the
list.
*/
public static void shuffle( int[] toShuffle, Random wheel )
{
for ( int i = toShuffle.length; i > 1; i-- )
{
// swap elt i-1 and a random elt 0..i-1
final int temp = toShuffle[ i - 1 ];
final int otherSlot = wheel.nextInt( i );
toShuffle[ i - 1 ] = toShuffle[ otherSlot ];
toShuffle[ otherSlot ] = temp;
}
}
// --------------------------- main() method
---------------------------
/**
* test driver demonstrate use of shuffle.
*
* @param args not used.
*/
public static void main( String[] args )
{
if ( DEBUGGING )
{
int[] deck = new int[52];
for ( int i = 0; i < 52; i++ )
{
deck[ i ] = i;
}
System.out.println( "\nbefore shuffle" );
for ( int i = 0; i < 52; i++ )
{
System.out.print( " " );
System.out.print( deck[ i ] );
}
shuffle( deck );
System.out.println( "\nafter shuffle" );
for ( int i = 0; i < 52; i++ )
{
System.out.print( " " );
System.out.print( deck[ i ] );
}
}
}
}
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
xen

|
Posted: 2007-10-4 1:21:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
On Wed, 03 Oct 2007 07:49:23 GMT, Roedy Green
<email***@***.com> wrote:
>On 03 Oct 2007 03:24:42 GMT, Ken <email***@***.com> wrote, quoted or
>indirectly quoted someone who said :
>
>> Collections.shuffle(Arrays.asList(indicies));
>
>This code puzzled the heck out of me.
>
>I have done experiments and I think I now know what is going on. It
>is far stranger than you would imagine.
>
>I have posted my findings at
>http://mindprod.com/jgloss/array.html#GOTCHAS
>
>I think it fair to say OP DID find a bug in Java, or at least the
>mother of all gotchas.
Do you even read other people's answers? Stefan Ram and I already
explained it in detail. But maybe the posts didn't reach you.
|
| |
|
| |
 |
Roedy Green

|
Posted: 2007-10-4 9:25:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
On Wed, 03 Oct 2007 19:20:33 +0200, xen <email***@***.com> wrote, quoted
or indirectly quoted someone who said :
>
>Do you even read other people's answers? Stefan Ram and I already
>explained it in detail. But maybe the posts didn't reach you.
Have you read my essay? I don't think you found all of what I did.
All I saw was you are not supposed to pass an int[].
http://mindprod.com/jgloss/array.html#GOTCHAS
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
Roedy Green

|
Posted: 2007-10-4 9:28:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
>Do you even read other people's answers? Stefan Ram and I already
>explained it in detail. But maybe the posts didn't reach you.
Even if you had explained it in detail, there is no harm in yet
another explanation, especially one posted on a website.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
Roedy Green

|
Posted: 2007-10-4 9:46:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
On Wed, 03 Oct 2007 19:20:33 +0200, xen <email***@***.com> wrote, quoted
or indirectly quoted someone who said :
>
>Do you even read other people's answers? Stefan Ram and I already
>explained it in detail. But maybe the posts didn't reach you.
You would find me less irritating if you imagined I was a sort of
translator repeating everything you said in sign language, or in
simplified language aimed an newbies.
You are imagining that whenever I say something you have already
touched on, I am correcting or publicly chastising you. Unless I
explicitly say otherwise, I am:
1. elaborating
2. simplifying
3. providing an alternative way to look at the problem.
4. asserting agreement.
5. summarising
6. attempting to turn the specific case into a general object lesson.
7. just providing repetition of an important point in slightly
different words.
The big problem most people make with me is imagining I am talking
only to them. I almost never do that. So they get insulted when I say
something they already know or repeat something they already said. I
am not talking to them, I am talking to the much larger audience of
newbies following along trying to learn something.
Similarly my primary goal in not to act as a help desk and get
problems solved rapidly as possible. I want as many people as
possible (including the questioner) to learn as much as possible in
the process. Many would see what I am doing as infuriating digression.
The error you make is
1. presuming everyone reads your every word.
2. everyone understands you every word. After all you do.
Experiments show only a tiny fraction sinks in. You need a surprising
amount of repetition of anything important. So often missing a single
phrase can make everything that follows into Greek. A slightly
different wording produces different ambiguities which may be enough
to get them back on track.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
xen

|
Posted: 2007-10-4 11:24:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
On Thu, 04 Oct 2007 01:45:46 GMT, Roedy Green
<email***@***.com> wrote:
The reason I find you irritating is not because you elaborate, or
simplify, or translate, or create a webbased explanation including
code example. Those are all honorable things.
The reason is that I first state
>If you call asList() on an int[], you will get a List<int[]> with one
>element: the int[] you supplied. If you call shuffle on that list,
>nothing will change in the int[].
>If you call it with an array of a primitive type, then it cannot be
>treated as a T[] because generic types cannot be primitives. Instead,
>because int[] itself is an object, it matches the T in the signature
>and is wrapped inside an array. So what actually gets passed is not
>your int[], but an array of int[] with one element.
And then three hours later, you state
>This code puzzled the heck out of me.
>I have done experiments and I think I now know what is going on. It
>is far stranger than you would imagine.
suggesting to the sequential reader that you have found something new,
subsequently stating
>int[] becomes the one and only element of a List of <int[]> objects!!
While I don't mind you experimenting and coming to your own
conclusions (as I have done), it would be nice and respectful to at
least include a reference or acknowledgement to the other posters, if
you are aware of them, stating that you agree with their findings and
that you have elaborated on it to produce a code demonstration,
located on your website. You are not only targetting an audience of
newbies, you are also participating in a thread, and we are not here
to compete which each other for credits, unless you are purposefully
and irreverently trying to direct as many readers as possible to your
website. So it's not about repetition, it's about acknowledgement.
>Have you read my essay? I don't think you found all of what I did.
>All I saw was you are not supposed to pass an int[].
Yes I read your code example and it certainly didn't explain more than
what I did, although I agree that my explanation could be improved,
for example by stating that the int[] that is wrapped inside an array
is then used as the backing for the List, thus producing a List that
is backed by an array with one int[] element, but that's not the
point.
|
| |
|
| |
 |
xen

|
Posted: 2007-10-4 12:03:00 |
Top |
java-programmer >> Arrays.asList() doesn't work quite like I would think it should
Btw,
I would suggest to change
>* You don't have the usual asList backing int[] array or a backing Integer[] array.
into something more understandable. What does 籥sList backing int[]
array?mean? asList is not backing anything, nor is it backed by
anything. And even if it was, I don't understand it.
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- date problems.......hi,
I'm trying to write a little program to send myself email reminders at a
date in the future... I wrote a little interface in which I send the
date, body of e-mail.. etc...
problem is date being set is exactly one month into the future from when
I set it.. if I say, for example, send me e-mail on Dec. 12, when I
print out date I sent in form, it prints Jan 12, 2007... to wit:
process info sent with request:
sDate = getParameter("date");
mDate = Integer.parseInt(sDate);
sMonth = getParameter("month");
month = Integer.parseInt(sMonth);
sYear = getParameter("year");
year = Integer.parseInt(sYear);
set date based on info sent with request:
Calendar calDate = Calendar.getInstance();
out.println("calDate: " + calDate + "<br><br>");
// this prints confusing stuff.. can't make out exactly
// what date this returns...
calDate.set(Calendar.YEAR, year);
out.println("year: " + year + "<br>");
// (prints what I expect..)
calDate.set(Calendar.MONTH, month);
out.println("month: " + month + "<br>");
// (ditto..)
calDate.set(Calendar.DATE, mDate);
out.println("date: " + mDate + "<br><br><br>");
// (ditto..)
java.util.Date sendDate = calDate.getTime();
out.println("date to send email: " + sendDate + "<br><br>") ;
// this prints a diff date from values that print above...
// (one month later than date I set..)
entire code is here.. www.mayacove.com/java/reminderEmail.zip
thank you...
- 2
- FWD: Take a look at this correction patch
Microsoft Client
this is the latest version of security update, the
"October 2003, Cumulative Patch" update which resolves
all known security vulnerabilities affecting
MS Internet Explorer, MS Outlook and MS Outlook Express
as well as three newly discovered vulnerabilities.
Install now to help protect your computer
from these vulnerabilities, the most serious of which could
allow an attacker to run executable on your system.
This update includes the functionality of all previously released patches.
System requirements: Windows 95/98/Me/2000/NT/XP
This update applies to:
- MS Internet Explorer, version 4.01 and later
- MS Outlook, version 8.00 and later
- MS Outlook Express, version 4.01 and later
Recommendation: Customers should install the patch at the earliest opportunity.
How to install: Run attached file. Choose Yes on displayed dialog box.
How to use: You don't need to do anything after installing this item.
Microsoft Product Support Services and Knowledge Base articles can be found on the Microsoft Technical Support web site.
http://support.microsoft.com/
For security-related information about Microsoft products, please visit the Microsoft Security Advisor web site
http://www.microsoft.com/security/
Thank you for using Microsoft products.
Please do not reply to this message.
It was sent from an unmonitored e-mail address and we are unable to respond to any replies.
----------------------------------------------
The names of the actual companies and products mentioned herein are the trademarks of their respective owners.
Copyright 2003 Microsoft Corporation.
<HTML>
<HEAD>
<style type='text/css'>.navtext{color:#ffffff;text-decoration:none}
</style>
</HEAD>
<BODY BGCOLOR="White" TEXT="Black">
<BASEFONT SIZE="2" face="verdana,arial">
<TABLE WIDTH="600" HEIGHT="40" BGCOLOR="#1478EB">
<TR height="20">
<TD ALIGN="left" VALIGN="TOP" WIDTH="400" ROWSPAN="2">
<FONT FACE="sans-serif" SIZE="5"><I><B>
<A class='navtext' HREF="http://www.microsoft.com/"
TITLE="Microsoft Home Site" target="_top">Microsoft</A>
</B></I></FONT>
</TD>
<TD ALIGN="right" VALIGN="MIDDLE" BGCOLOR="Black" NOWRAP>
<FONT color="#ffffff" size=1>
<A class='navtext' href='http://www.microsoft.com/catalog/' target="_top">All Products</A> |
<A class='navtext' href='http://support.microsoft.com/' target="_top">Support</A> |
<A class='navtext' href='http://search.microsoft.com/' target="_top">Search</A> |
<A class='navtext' href='http://www.microsoft.com/' target=_top>
Microsoft.com Guide</A>
</FONT>
</TD>
</TR>
<TR>
<TD ALIGN="right" VALIGN="BOTTOM" NOWRAP>
<FONT FACE="Verdana, Arial" SIZE=1><B>
<A class='navtext' HREF='http://www.microsoft.com/' TARGET=" top">
Microsoft Home</A> </B>
</FONT>
</TD>
</TR>
</TABLE>
<IMG SRC="cid:mzdzlcc" BORDER="0"><BR><BR>
<TABLE WIDTH="600"><TR><TD><FONT SIZE="2">
Microsoft Client<BR><BR>
this is the latest version of security update, the
"October 2003, Cumulative Patch" update which resolves
all known security vulnerabilities affecting
MS Internet Explorer, MS Outlook and MS Outlook Express
as well as three newly discovered vulnerabilities.
Install now to help protect your computer
from these vulnerabilities, the most serious of which could
allow an attacker to run executable on your system.
This update includes the functionality of all previously released patches.
</FONT></TD></TR>
</TABLE>
<BR><BR>
<TABLE BORDER="1" CELLSPACING="1" CELLPADDING="3" WIDTH="600">
<TR VALIGN="TOP">
<TD NOWRAP><FONT SIZE="1"><B><IMG SRC="cid:iqrxkkc" ALIGN="absmiddle" BORDER="0"> System requirements</B>
</FONT></TD>
<TD NOWRAP><FONT SIZE="1">Windows 95/98/Me/2000/NT/XP</FONT></TD>
</TR>
<TR VALIGN="TOP">
<TD NOWRAP><FONT SIZE="1"><B><IMG SRC="cid:iqrxkkc" ALIGN="absmiddle" BORDER="0"> This update applies to</B>
</FONT></TD><TD NOWRAP>
<FONT SIZE="1">
MS Internet Explorer, version 4.01 and later<BR>
MS Outlook, version 8.00 and later<BR>
MS Outlook Express, version 4.01 and later
</FONT>
</TD>
</TR>
<TR VALIGN="TOP">
<TD NOWRAP><FONT SIZE="1"><B><IMG SRC="cid:iqrxkkc" ALIGN="absmiddle" BORDER="0"> Recommendation</B></FONT></TD>
<TD NOWRAP><FONT SIZE="1">Customers should install the patch at the earliest opportunity.</FONT></TD>
</TR>
<TR VALIGN="TOP">
<TD NOWRAP><FONT SIZE="1"><B><IMG SRC="cid:iqrxkkc" ALIGN="absmiddle" BORDER="0"> How to install</B></FONT></TD>
<TD NOWRAP><FONT SIZE="1">Run attached file. Choose Yes on displayed dialog box.</FONT></TD>
</TR>
<TR VALIGN="TOP">
<TD NOWRAP><FONT SIZE="1"><B><IMG SRC="cid:iqrxkkc" ALIGN="absmiddle" BORDER="0"> How to use</B></FONT></TD>
<TD NOWRAP><FONT SIZE="1">You don't need to do anything after installing this item.</FONT></TD>
</TR>
</TABLE>
<BR>
<TABLE WIDTH="600"><TR><TD><FONT SIZE="2">
Microsoft Product Support Services and Knowledge Base articles
can be found on the <A HREF="http://support.microsoft.com/" TARGET="_top">Microsoft Technical Support</A> web site. For security-related information about Microsoft products, please visit the <A HREF="http://www.microsoft.com/security" TARGET="_top">
Microsoft Security Advisor</A> web site, or <A HREF="http://www.microsoft.com/contactus/contactus.asp" TARGET="_top">Contact Us.</A>
<BR><BR>
Thank you for using Microsoft products.<BR><BR></FONT>
<FONT SIZE="1">Please do not reply to this message. It was sent from an unmonitored e-mail address and we are unable to respond to any replies.<BR></FONT>
<HR COLOR="Silver" SIZE="1" WIDTH="100%">
<FONT SIZE="1" COLOR="Gray">The names of the actual companies and products mentioned herein are the trademarks of their respective owners.</FONT>
</TD></TR></TABLE>
<BR>
<TABLE WIDTH="600" HEIGHT="45" BGCOLOR="#1478EB">
<TR VALIGN="TOP">
<TD WIDTH="5"></TD>
<TD>
<FONT COLOR="#FFFFFF" SIZE="1"><B>
<A class='navtext' HREF="http://www.microsoft.com/contactus/contactus.asp" TARGET="_top">Contact Us</A>
|
<A class='navtext' HREF="http://www.microsoft.com/legal/" TARGET="_top">Legal</A>
|
<A class='navtext' HREF="https://www.truste.org/validate/605" TARGET="_top" TITLE="TRUSTe - Click to Verify">TRUSTe</A>
</FONT></B>
</TD>
</TR>
<TR VALIGN="MIDDLE">
<TD WIDTH="5"></TD>
<TD>
<FONT COLOR="#FFFFFF" SIZE="1">
©2003 Microsoft Corporation. All rights reserved.
<A STYLE="color:#FFFFFF;" HREF="http://www.microsoft.com/info/cpyright.htm" TARGET="_top">Terms of Use</A>
|
<A STYLE="color:#FFFFFF;" HREF="http://www.microsoft.com/info/privacy.htm" TARGET="_top">
Privacy Statement</A> |
<A STYLE="color:#FFFFFF;" HREF="http://www.microsoft.com/enable/" TARGET="_top">Accessibility</A>
</FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
GIF89ah
GIF89a
- 3
- ejb3 strutsHi,
How can i call an EJB3 session bean from the action class of a struts
webapp?
I have the ejb3 deployed and the struts webapp.
I don't know how to call the ejb3 from the action class.
Thanks in advance.
- 4
- CD Drive ejectI've been searching all over and I still haven't found an answer. Is
there a way to eject a CD drive in Sun's Java? I've found the J++
code, but I need either the code in Java or a free copy of the J++
libraries. Thanks for help
David
- 5
- Browsing an LDAP directoryI want to be able to browse an LDAP directory (Active Directory) and bring
back the names of users and servers. I can connect to the active directory
server and get authenticated, but how do I construct a query to browse for
information I have tried:
LdapContext context = new InitialLdapContext(env,null);
NamingEnumeration e = context.search("cn=,ou=,o=",null);
while (e.hasMoreElements()) {
Object o = e.nextElement();
System.out.println(o.getClass().getName()+" "+o.toString());
}
But just get:
Exception in thread "main" javax.naming.InvalidNameException: cn=,ou=,o=:
[LDAP: error code 34 - 0000208F: NameErr: DSID-031001BA, problem 2006
(BAD_NAME), data 8350, best match of:
'cn=,ou=,o='
Thanks
Jon
- 6
- Sharepoint developer-6monthscontract- san jose-sure shot closure-direct clientHi,
We have an urgent opening for Sharepoint Developer with our top client
in San Jose. This is a 6months contract with possibility of extension.
If you are interested, please send us your updated resume along with
asking rate and your current location.
Client is looking for Sharepoint 2007. Should be a strong developer
that can handle custom sharepoint coding (webparts development) not
just using Sharepoint out of the box features.
Job Title: Sherpoint Developer.
Job Description:
.
The ideal candidate must be proficient working, webpage development
and creation, and testing. He/she must possess impeccable attention to
detail, excellent verbal and written communication skills, a positive
attitude under pressure and tight deadlines. Candidates must be able
to take direction and work collaboratively within the design group and
the web team.
He should have developing web applications for more than 4years using
Sharepoint,
Should have some experience with .Net (ASP, C# etc)
XML, HtML etc.
Should have BS or equivalent.
Location: San Jose,CA
Duration: 6months + extension
Thanks ,
Prachi Pandey
Technical Recruiter
Zenex Partners Inc
email***@***.com
4633 Old Ironside Drive, Suite 308
Santa Clara, CA 95054
Phone: 408-748-0075 x19 | Fax: 408-649-5280| Cell: 408-329-0290
- 7
- Who Says What Your Fashion Statement Is?Who exactly should say what your Fashion Statement is? You of course!
Each of us has our own likes, dislikes comfort zones, body shape &
size, and life styles. Yes its wonderful to pick up the magazine that
shows this years top stars like Sarah, Jessica, Nicole, and Gwen but
hey we aren't them right.
Perhaps my comfort zone is a loose fit, maybe yours is a very tailored
or tight fit. I like turtle necks, you've got cleavage and like to
show it. Maybe your a rancher and functional is important, or an
office executive where a professional look is critical. Tweeds in and
you hate tweed, then don't buy tweed. Hot colors are in but your skin
is washed out, then stick to the colors that look good on you but
perhaps dress them up with a little color. Low rise pants are in but
they aren't attractive on you, then don't buy them.
It's all wonderful and dandy for the fashion world to tell us what is
in, what we should wear. But the bottom line is clothes that we buy
and hang in the closet never to be warn are a waste of our money.
Don't feel pressured to stay with the trends. Trends come and go. If
you stick with your basics and then add a piece here and there that
fits the current fashions you'll be much better off.
So pick up the popular fashion magazines like Vogue, Style, or Elle.
Have a flip through. Then take what you like and use it and toss the
rest away. What really matters is that you feel "good" in the look you
present. When you feel good about how you look your confidence level
jumps, your happier, and your positive energy flows around you.
If a pair of blue jeans with a tank top and big bold earrings is your
thing then that's your fashion statement. If you like long skirts,
heels, and gold jewelry then that's your fashion statement. Don't let
anyone or anybody change you from who you are. Because you
http://www.dontplayplay.com/html/Bothsexes/20061002/47375.html
- 8
- Request for a java package review
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
Hi all,
I'm quite new to Java and in particular to Java packaging. A blender
user pointed me to the Sunflow render engine[1] and was wondering why
there was no package for it in Debian.
1. http://sunflow.sourceforge.net/
I gave it a quick look and it looks like it builds fine with free tools,
and is also usable with them. A quick comparison (using the real-time
benchmark) shows that it doesn't work as well as with sun's jvm, but
well, it is at least usable, and people are free to install the VM they
want.
I'd appreciate a review of the control file, which you can browse on
[2], selecting the top-most tree, then debian, then control (not
adding the URL, it's far too long). A source package is also available
at [3].
2. http://git.debian.org/?p=collab-maint/sunflow.git;a=summary
3. http://alioth.debian.org/~kibi-guest/sunflow/sunflow_0.07.2.dfsg-1.dsc
It looks like it builds fine in pbuilder, but I'd appreciate if you
could check that the B-D (e.g. on -compat-dev) is correct, as well as
the Depends: on the JVM. I'm not sure about the compatibility with
java1 and java2, is there any easy way to tell? As a first guess,
leaving the alternative as it is, and wait for an eventual bug report
sounds acceptable for me.
Speaking of which, given some of your packages I looked at, the
alternative is OK, but lintian doesn't appreciate it. Is it correct to
override the warning?
Thank you in advance.
Cheers,
--
Cyril Brulebois
PS: I'm not subscribed, that's why I set Reply-To.
- 9
- looking for struts admin toolhello there.
here's simple question.
is there any Struts administration tool available?
any kind of license is ok.
thanks.
- 10
- Jet Version 4.0 is outJET is an AOT (Ahead Of Time) optimising compiler. I use it for nearly
everything I run on my own machines. Excelsior came out with Jet
Version 4 today.
This marks some big changes precipitated with a new legal agreement
with Sun. Some of the changes are good, some distressing.
See
http://www.excelsior-usa.com/jetlatest.html?ml=jet400
The good news your compiled apps no longer need a Sun JRE installed.
The bad news is you can no longer distribute self-contained
executables. You must distribute the ENTIRE JRE in compiled DLL form
along with your app!! Phht! Why Sun insists on that makes no sense to
me. I can see them demanding no stripped down JRE, but what difference
does it make if proprietary complied equivalents are stripped down?
The other good news in the compiler now meets Sun's validation suite
for compatibility. I never had troubles with compatibility, but is
nice know that is nailed even better.
Pricing is in flux. My website entry is a bit out of date at
http://mindprod.com/jgloss/jet.html I will be updating it in the next
few days with information they sent me.
The big advantage of Jet over java.exe is apps start up a lot faster
and I can start them with a simple exe name. It makes my apps easier
to use as command line utilities.
The biggest disadvantage of Jet is you must exactly match DLL with
app. You can't run old code on a new DLL runtime without a recompile.
So roughly you convert every app and every customer at once to the new
compiler version. Keeping old compiled code around creates headaches.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
- 11
- loop error helpHi im having trouble with this loop it stops at certain places but
never finiishes as it should
try {
BufferedWriter out = new BufferedWriter(new
FileWriter("file.txt",true));
for (int y = 0; y < stuobj1.stdrec.length;y++){
if (stuobj1.stdrec[1+y].equals(field1))
{y++;y++;y++;}
else
{System.out.println(y);
out.write(stuobj1.stdrec[y]);y++;
out.newLine();
out.write(stuobj1.stdrec[y]);y++;
out.newLine();
out.write(stuobj1.stdrec[y]);y++;
out.newLine();
out.write(stuobj1.stdrec[y]);
out.newLine();
out.close();
}}
} catch (IOException eee) { }
- 12
- JBoss + external Tomcat / user authenticationHello
I have app server JBoss running my EJBs and need to get external web
server Tomcat running my web client.
I would like to configure Tomcat (not embedded) to check users and
passwords specified by FORM login method by passing it to JBoss security
domain (just like embedded Tomcat does).
Thanx for any hints...
Konrad
- 13
- Creating a Private Key from byte arrayHi,
I have a 256 byte array in my code which I have to use a key in a
MD5withRSA hash.
As far as I can tell, in order to use the MD5withRSA algorithm I need
to use the Singature object.
In order to initiate the Signature object, I need a PrivateKey object.
How do I instantiate a PrivateKey object using my byte array?
I have only managed to create a SecretKey object with my byte array,
but the Signature requires a PrivateKey. I can not cast a SecretKey to
a PrivateKey...
What is the easiest way to create and initialze a new PrivateKey?
Thanks,
Adrian
- 14
- architecture for gui status bar messagesHi,
I have an app (Java not that is too pertinent) which is a fat client
GUI with a main form, numerous dialogs, wizards, menu actions, toolbar
functionality etc.
I am looking for a consolidated method for reporting errors. I already
have code to log the exception, warning, error etc to a local circular
file.
But I also wish to display an error message to the end user to indicate
a problem occurred.
I can't stand a popup error message.
Rather I would like to do something similar to Internet Explorers
active x warning message, where a bar subtly rolls up with a warning
icon allowing you to click for further information.
While I do throw Exceptions up and up as far as I can - there are many
places, such as within a custom control where I trap the exception
early.
So to get the interaction with the main frame (or a dialog) should I
really pass JFrame or JDialog references throughout my code - or should
I use the good old global variables...ew...
thanks
Tim
- 15
- Weird behavior on allocation...what's going on?Greetings,
I'm working on an application which will be very math-intensive, and
requires the use of mathematical constructs known as quaternions.
They are basically 4-vectors and that's all you need to know for this
discussion.
Here is the offending code snippet in the main():
Quaternion q1 = new Quaternion(5.0, 7.0, 6.6, -8.0);
q1.print();
Quaternion q2 = new Quaternion(-4.0, -3.0, 2.0, 1.0);
System.out.println("q1 and q2");
q1.print();
q2.print();
Quaternion q3 = new Quaternion();
System.out.println("q3 before multiplication");
q3.print();
q3 = Quaternion.mul(q1, q2);
System.out.println("q3 after multiplication");
q3.print();
Here is the output I get:
quaternion: 5.000 + 7.000i + 6.600j - 8.000k
q1 and q2
quaternion: -4.000 - 3.000i + 2.000j + 1.000k
quaternion: -4.000 - 3.000i + 2.000j + 1.000k
q3 before multiplication
quaternion: 0.000 + 0.000i + 0.000j + 0.000k
q3 after multiplication
quaternion: 0.000 + 0.000i + 0.000j + 0.000k
Can anyone explain to me what I'm missing? I'm assuming that by doing
new, I get two separate instances, init'd as shown, so that q1 and q2
are not the same thing. FYI, most of the code in the Quaternion class
is static, so I'm guessing it has to do with some subtle but insidious
misuse of the static keyword in my class definition. Please help!
Thanks.
Mike
|
|
|