| New technology, old idea.... why not? |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- Good JDO tutorial ?I'm trying to learn JDO and am having a tought time getting started.
I'm using Eclipse and have downloaded the Triactive JDO. (It seemed
rated pretty well and it's free)
I'm using SQL Server
I'd prefer not to use enhancement because it doesn't sound like the
right approach, but I guess I could try it if the tutorial was good
Can someone point me in the right direction? I don't mind trying a
different JDO (as long as it is free). But I want to go against sql server.
Chip
- 3
- JMX, way to know if NotificationEmitter is alive?Hi, I'm facing a JMX problem,
I'm working in an aplication that uses JMX to send update messages
from a MBeanServer to several consoles.
The architecture is: a MBeanServer that emits JMX Notifications and
several Java-Web-Start-based console's applications that are
NotificationListeners, registered as listeners of the MBean that emits
the Notifications at the server side.
I want to know if there is a way from the different consoles to check
if the NotificationEmitter is alive and sending Notifications.
Any idea?
(please, don't answer that the way to know that the server is down is
that you don't receive more Notifications)
thanks,
Kun
- 8
- Returning an objectHi, I am after some advice regarding returning an object called for in
one class and constructed in another.
The class that constructs the object has around ten methods that if
successful will all be called during creation of the object however
each method could throw an exception due to IO errors so I was
wondering how do you code something like this.
The calling class currently calls a single method in the creation
class which in turn makes calls to another method and so on until the
object is built, this is fine if all goes well but how do you deal
with an exception.
If an exception is thrown the object will not be built and the calling
class will have no object to deal with.
I guess you can use boolean return values for each method in the
creation class and return null or another sensible value to the caller
if something goes wrong but this seems clunky.
Any advice would be appreciated.
Thanks,
M.
- 8
- Caret Positioning in a JFormattedTextField ?Hi I've a attached a demo bit of code to go along with the problem explanation that follows.
Basically I have found that if I have a simple JFormattedTextField but assign a formatter to it and
an inputverifier the caret always seems to be set on the left had side when focus is given, even if
you try and force the position on a focus even.
In the following example I have two JFormattedTextFeilds, one is normal with no changes made, its
set to 10 if you change the cursor position and then tab out and tab back in the position is
remembered. The other field however has the formatter and verifier on it. It doesn't remember the
cursor position and even if I try and catch the focus and set it to position 1 it has no effect.
Has anybody any idea's if this is a problem with my code or maybe even the Sun classes ? There are
probably much better ways of doing this. But basically I wanted to stop the user losing focus if an
invalid value was entered, say 1000, but obviously when focus is regained if they want to edit the
value they don't want to have to move the cursor to the end again.
Try it out.
Cheers
Steve
-----------------------------
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.text.NumberFormat;
import java.text.ParseException;
import javax.swing.*;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.NumberFormatter;
public class testframe extends JFrame {
/** Creates new form testframe */
public testframe() {
initComponents();
noneValidatedField.setText("10");
setupIntegerEditor(validatedtField, 10, 1, 999);
}
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jPanel1 = new javax.swing.JPanel();
validatedtField = new javax.swing.JFormattedTextField();
noneValidatedField = new javax.swing.JFormattedTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
jPanel1.setLayout(new java.awt.GridBagLayout());
validatedtField.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
validatedtFieldFocusGained(evt);
}
public void focusLost(java.awt.event.FocusEvent evt) {
validatedtFieldFocusLost(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.ipadx = 169;
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
jPanel1.add(validatedtField, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.ipadx = 169;
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
jPanel1.add(noneValidatedField, gridBagConstraints);
getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
pack();
}
private void validatedtFieldFocusLost(java.awt.event.FocusEvent evt) {
validatedtField.setCaretPosition(1);
}
private void validatedtFieldFocusGained(java.awt.event.FocusEvent evt) {
validatedtField.setCaretPosition(1);
}
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
private void setupIntegerEditor(final JFormattedTextField jftf, int
value, int min, int max) {
// Create integer formatter setting the min and max integer values
NumberFormat integerFormat = NumberFormat.getIntegerInstance();
NumberFormatter intFormatter = new NumberFormatter(integerFormat);
intFormatter.setMinimum(new Integer(min));
intFormatter.setMaximum(new Integer(max));
jftf.setFormatterFactory(new DefaultFormatterFactory(intFormatter));
jftf.setInputVerifier(new QtyVerifier());
jftf.setValue(new Integer(value));
// Setup input map
jftf.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
jftf.getActionMap().put("check", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
NumberFormatter formatter = (NumberFormatter)jftf.getFormatter();
if(formatter != null) {
try {
formatter.stringToValue(jftf.getText());
System.out.println("value is valid on enter");
} catch (ParseException pe) {
jftf.selectAll();
System.out.println("Value must be between " +
formatter.getMinimum() + " and " + formatter.getMaximum());
}
}
}
});
}
class QtyVerifier extends InputVerifier {
public QtyVerifier() {
}
public boolean verify(JComponent input) {
if(!(input instanceof JFormattedTextField))
return true;
JFormattedTextField jftf = (JFormattedTextField)input;
NumberFormatter formatter =
(NumberFormatter)jftf.getFormatter();
if(formatter == null)
return true;
try {
formatter.stringToValue(jftf.getText());
System.out.println("value is valid on qty check ");
return true;
} catch (ParseException pe) {
jftf.selectAll();
System.out.println("Value must be between " +
formatter.getMinimum() + " and " + formatter.getMaximum());
}
return false;
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new testframe().show();
}
// Variables declaration - do not modify
private javax.swing.JPanel jPanel1;
private javax.swing.JFormattedTextField noneValidatedField;
private javax.swing.JFormattedTextField validatedtField;
// End of variables declaration
}
--
Please remove 'y' from return address to reply (Anti Spam !!)
- 9
- Simultaneous keypresses in Pong gameHi,
i have created a Pong game Application where two players control their
pads using the keyboard. the problem is that one player is using the
action keys
VK_UP and VK_DOWN in keyPressed() and the other, characters 'w' and
's' in keyTyped(). when both players hit a key simultaneously and keep
it pressed then only one of the two pads move. on the other hand if
both hit their keys fast then everything works ok. i declared both
keyPressed and keyTyped as "synchronized" but it doesn't seem to work.
what can i do in order to process them simultaneously? there is a run
method in my application as well.
thank you
- 9
- /Z4 Almost FREE MONEY !! /Z4MAKE MONEY!!!
MAKE THOUSANDS!!!
I found this on a bulletin board and decided to try it: I don't care about
the useless pre-fabricated crap this message usually says. All I say is, it
works. Continue pre-fab crap.
WELL GUESS WHAT!!!
Within seven days, I started getting money in the mail!! I
was shocked!! I figured it would end soon, but the money just kept
coming in. In my first week, I made about $25.00. By the end of the second
week I had made a total of more than $1000.00!!
Let me tell you how this works and most important, why it works..........
also make sure you print this out NOW, so you can get the information off
of it, as you will need it. I promise you that if you follow the directions
exactly that you will start making more money than you thought possible by
doing something
so easy!!
Suggestion: Read this entire message carefully!! (Print it out or download
it)
Follow the simple directions and watch the money come in!! It's easy.
It's legal. And, your investment is only $6.00 (Plus postage) !!!
You can use any currancy as people can always change it..
IMPORTANT:
This is not a rip-off, it is decent; it's legal; and it is virtually no
risk - it really works!! If all the following instructions are adhered to,
you will receive extraordinary dividends.
PLEASE NOTE:
Please follow the directions EXACTLY, and $50,000 or more can be yours
in 20 to 60 days. This program remains successful because of the honesty
and integrity of the participants. Please continue its success by carefully
adhering to the instructions. You will now become apart of the Mail Order
business.
You are in the business of developing Mailing Lists. Many large corporations
are happy to pay big bucks for quality lists. However, the money made from
the
mailing lists is secondary to income which is made from people like you
and me asking to be included in that list. Here are the four easy steps to
success.
STEP ONE:
Get six separate pieces of paper and write the following on
each piece of paper "PLEASE PUT ME ON YOUR MAILING LIST."
Now get 6 U.S. $1.00 bills and place ONE inside of EACH of the six pieces
of paper so the bill will not be seen through the envelope (to prevent
thievery). Next, place one paper in each of the six envelopes and seal them.
You now should have six sealed envelopes, each with a piece of paper stating
the above phrase, your name and address, and a $1.00 bill. What you are
doing is creating a service.
THIS IS ABSOLUTELY LEGAL!!!!!
You are requesting a legitimate service and you are paying for it!! Like
most of us I was a little skeptical and little worried about the legal
aspects of it all. So I checked it out with the U.S. Post Office
(1-800-238-5355)
and they confirmed that it is indeed legal!!
Mail the six envelopes to the following addresses:
Matthew Dutton
46 Hayworth St
Point Vernon, Hervey Bay
QLD, 4390
Australia
R. Visser
P.O. Box 274
Nobby Beach
QLD, 4218
Australia
S. Phillips
77 Manly Drive
Robina, QLD 4226
Australia
Chris Pittman
7651 Abigail Glen Dr.
Charlotte, NC 28212
USA
Mike Vango
29 Pebblewood Ave
Scarborough, ON M1V-2A7
Canada
C. Wehler
137 Sara Rd
St. Marys, PA 15857
USA
STEP TWO:Now take the #1 name off the list that you see above, move the
other names up (six becomes 5, 5 becomes 4, and etc.) and add YOUR NAME as
number 6 on the list.
STEP THREE:
Change anything you need to but try to keep this article as close to
original as possible. Now post your amended article to at least 200 news
groups. : (I think there are close to 24,000 groups) All you need is 200,
but
remember, the more you post, the more money you make!! This is perfectly
legal!! If you have any doubts, refer to Title 18 Sec. 1302 & 1341 of the
Postal Lottery laws. Keep a copy of these steps for yourself and whenever
you need money, you can use it again, and again. PLEASE REMEMBER that this
program remains successful because of the honesty and integrity of the
participants and by their carefully adhering to directions. Look at it this
way. If you were of integrity, the program will continue and the money that
so many others have received will come your way.
NOTE: You may want to retain every name and address sent to you,> either on
a computer or hard copy and keep the notes people send you.
This VERIFIES that you are truly providing a service. (Also, it might be
a good idea to wrap the $1 bill in dark paper to reduce the risk of mail
theft). So, as each post is downloaded and the directions carefully
followed, all members will be reimbursed for their participation as a List
Developer with one dollar each. Your name will move up the list
geometrically so that when your name reaches the #1 position you will be
receiving thousands of dollars in CASH!!! What an opportunity for only $6.00
( $1.00 for each of the first six people listed above) Send it now, add your
own name to the list and you're in business!!!
*****DIRECTIONS FOR HOW TO POST TO NEWS GROUPS!!!*****
STEP ONE: You do not need to re-type this entire letter to do your own
posting. Simply put your cursor at the beginning of this letter and drag
your cursor to the bottom of this document, and select 'copy' from the edit
menu. This will copy the entire letter into the computer's memory.
STEP TWO:
Open a blank 'notepad' file and place your cursor at the top
of the blank page. From the 'edit' menu select 'paste'. This will paste a
copy of the letter into the notepad so that you will add your name to the
list.
STEP THREE:
Save your new notepad file as a text file. If you want to do your posting
in different settings, you'll always have this file to go back to.
STEP FOUR:
You can use a program like "postXpert" to post to all the newsgroups at
once. You can find this program at <<http://www.download.com>>.
Use Netscape or Internet Explorer and try searching for various new
groups (on- line forums, message boards, chat sites, discussions.)
STEP FIVE:
Visit message boards and post this article as a new message by
highlighting the text of this letter and selecting paste from the edit menu.
Fill in the subject, this will be the header that everyone sees as they
scroll through the list of postings in a particular group, click the post
message button. You're done.
Congratulations!!!!!!
THAT'S IT!! All you have to do, and It Really works!!!
BEST WISHES ...
ouYj\
- 9
- JFrame point object returns...what?If you check this method in the main class - JFrame frame = new
QuarterScreenFrame("This is a test", 1);
I'm just not sure what value of topLeft to put..
This is the main class --
public class QuarterScreenTester {
public static void main(String[] args) {
JFrame frame = new QuarterScreenFrame("This is a test", 0,1);
frame.setVisible(true);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
-*-*-*-*******************************
This is the sub-class ---
public QuarterScreenFrame(String title, Point topLeft) // creates a
frame with title
{
super(title);
int width;
int height;
int x,y;
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension dimensions =toolkit.getScreenSize();
topLeft = new Point (dimensions.width, dimensions.height);
x = topLeft.x;
y = topLeft.y;
setBounds(0,0,x,y);
}
- 11
- Connection timed outI want to test this code which establishes SSL connection with the
server. Why it throws the exception as below. Also, how to retrieve
the content of the desired page on that host?:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.security.Principal;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
public class MainClass {
public static void main(String[] args) throws Exception {
SSLSocketFactory factory = (SSLSocketFactory)
SSLSocketFactory.getDefault();
String hostName = "website.com";
String fileName = "";
SSLSocket sslsock = (SSLSocket) factory.createSocket(hostName,
443);
SSLSession session = sslsock.getSession();
X509Certificate cert;
try {
cert = (X509Certificate) session.getPeerCertificates()[0];
} catch (SSLPeerUnverifiedException e) {
System.err.println(session.getPeerHost() + " did not present a
valid certificate.");
return;
}
System.out.println(session.getPeerHost() + " has presented a
certificate belonging to:");
Principal p = cert.getSubjectDN();
System.out.println("\t[" + p.getName() + "]");
System.out.println("The certificate bears the valid signature
of:");
System.out.println("\t[" + cert.getIssuerDN().getName() + "]");
System.out.print("Do you trust this certificate (y/n)? ");
System.out.flush();
BufferedReader console = new BufferedReader(new
InputStreamReader(System.in));
if (Character.toLowerCase(console.readLine().charAt(0)) != 'y')
return;
PrintWriter out = new PrintWriter(sslsock.getOutputStream());
out.print("GET " + fileName + " HTTP/1.0\r\n\r\n");
out.flush();
BufferedReader in = new BufferedReader(new
InputStreamReader(sslsock.getInputStream()));
String line;
while ((line = in.readLine()) != null)
System.out.println(line);
sslsock.close();
}
}
Exception in thread "main" java.net.ConnectException: Connection timed
out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(Unknown Source)
at
com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(Unknown
Source)
at SSL.SSLTest.main(SSLTest.java:20)
- 11
- Everyone agrees that Java's date/time handling is terrible......but are there any alternatives? I have had a look around for replacement
libraries, but I cannot find anything that meets my needs. Most of the
available choices simplify the issues (for example, ignoring time of day,
ignoring timezones, or assuming the Gregorian calendar), or provide
functionality that will not be used (such as working with dates +/-100,000
years from now). I am searching for something that will manage dates/times
at various timezones around the world, and can convert points in time into
various local calendars.
Are there any projects under way that will provide a better implementation
of Sun's Date and Calendar classes to handle dates, times of day, timezones,
daylight savings times, and calendars?
Many thanks,
Greg Hawkes <email***@***.com>
(Remove ".despam" to reply, please)
- 11
- SEGV on jdk 1.5.0 @ amd64
Hi!
I have experienced two crashes pof the in the last 24 hours. This is on
freebsd-6.0-release @ amd64 with latest jdk-1.5.0p2_2
Hope this info can shed som light on this? Need more info? Just mail me.
/Palle
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# SIGSEGV (0xb) at pc=0x0000000800fed63c, pid=28464, tid=0x87b000
#
# Java VM: Java HotSpot(TM) 64-Bit Server VM
(1.5.0-p2-girgen_24_nov_2005_21_38 mixed mode)
# Problematic frame:
# V [libjvm.so+0x68f63c]
#
# An error report file with more information is saved as
/tmp/hs_err_pid28464.log
#
# If you would like to submit a bug report, please write
# a letter to email***@***.com mailing list
#
- 11
- Omega Deville 18kt Yellow Gold Midsize Watch 7120.14 ReplicaOmega Deville 18kt Yellow Gold Midsize Watch 7120.14 Replica, Fake,
Cheap, AAA Replica watch
Omega Deville 18kt Yellow Gold Midsize Watch 7120.14 Link :
http://www.aaa-replica-watch.com/Omega_7120.14.html
Buy the cheapest Omega Deville 18kt Yellow Gold Midsize Watch 7120.14
in toppest Replica . www.aaa-replica-watch.com helps you to save
money! Omega-7120.14 , Omega Deville 18kt Yellow Gold Midsize Watch
7120.14 , Replia , Cheap , Fake , imitation , Omega Watches
Omega Deville 18kt Yellow Gold Midsize Watch 7120.14 Information :
Brand : Omega Watches (http://www.aaa-replica-watch.com/
Replica_Omega.html )
Gender : Unisex
Model : Omega-7120.14
Case Material : 18kt Yellow Gold
Case Diameter : 7120.14, 7120.14.00, 7120-14, 7120-14-00, 7120/14,
712014, 7120
Dial Color : Ivory
Bezel : Fixed
Movement : Quartz
Clasp : 18kt Yellow Gold
Water Resistant : 30m/100ft
Crystal : Scratch Resistant Sapphire
Our Price : $ 268.00
Availability: Contact Us For Availability Omega Deville 18kt Yellow
Gold Midsize Watch 7120.14 18kt yellow gold case and bracelet.
Champagne dial. Date displays at 3 o'clock position. Gold hands and
hour markers. Quartz movement. Water resistant at 30 meters (100
feet). Omega Deville 18kt Yellow Gold Midsize Watch 7120.14 Omega
Deville 18kt Yellow Gold Midsize Watch 7120.14 Brand OmegaSeries Omega
DeVilleGender UnisexCase Material 18kt Yellow GoldDial Color
IvoryBezel FixedMovement QuartzClasp Domed Anti-reflective Scratch
Resistant SapphireBracelet 18kt Yellow GoldWater Resistant 30m/
100ftCrystal Scratch Resistant SapphireWarranty Warranty service for
this watch will be offered through Haob2b.com and not the
manufacturer. Omega watches have a 2 year Haob2b.com warranty. Please
click here for additional watch warranty information.Item Variations
7120.14, 7120.14.00, 7120-14, 7120-14-00, 7120/14, 712014,
7120Additional Information Date Displays at 3 O'clock PositionOmega
watches have been a standard for quality and excellence for over 150
years, when the company began as Switzerland's first watch
manufacturer. When elegance and strength come together to form an
extraordinary timepiece, the result can only be an Omega wristwatch.
Omega watches are proud to be endorsed by many of the world's leading
athletes and celebrities, the most prominent being Pierce Bronson as
James Bond and Cindy Crawford. Haob2b is proud to offer a full line of
Omega watches, featuring Omega Constellation, Omega Seamaster, Omega
Aqua Terra, Omega Speedmaster, Omega double eagle, Omega Broad Arrow,
and Omega Co-Axial at competitive prices.Omega Deville 18kt Yellow
Gold Midsize Watch 7120.14 is brand new, join thousands of satisfied
customers and buy your Omega Deville 18kt Yellow Gold Midsize Watch
7120.14 with total satisfaction . A Haob2b.com 30 Day Money Back
Guarantee is included with every Omega Deville 18kt Yellow Gold
Midsize Watch 7120.14 for secure, risk-free online shopping.
Haob2b.com does not charge sales tax for the Omega Deville 18kt Yellow
Gold Midsize Watch 7120.14, unless shipped within New York State.
Haob2b.com is rated 5 stars on the Yahoo! network.
Omega Deville 18kt Yellow Gold Midsize Watch 7120.14 Replica, With the
mix of finest craftsmanship and contemporary styling, not only does it
reflect the time but also care you put into looking good. choose one
to promote your quality and make yourself impressive among people
Thank you for choosing www.aaa-replica-watch.com as your reliable
dealer of quality waches including Omega Deville 18kt Yellow Gold
Midsize Watch 7120.14 . we guarantee every watch you receive will be
exact watch you ordered. Each watch sold enjoy one year Warranty for
free repair. Every order from aaa-replica-watches is shipped via EMS,
the customer is responsible for the shipping fee on the first order,
but since the second watch you buy from our site, the shipping cost is
free. Please note that If the total amount of payment is over
$600(USD), the customer is required to contact our customer service
before sending the money in case failed payment. If you have any other
questions please check our other pages or feel free to email us by
email***@***.com.
The Same Omega Watches Series :
Omega DeVille Ladies Watch 4870.31.01 :
http://www.aaa-replica.com/Omega_4870.31.01.html
Omega DeVille Co-Axial Ladies Watch 4581.31 :
http://www.aaa-replica.com/Omega_4581.31.html
Omega DeVille Co-Axial Chronograph Mens Watch 4841.20.32 :
http://www.aaa-replica.com/Omega_4841.20.32.html
Omega DeVille Co Axial Chronograph Power Reserve Watch 4632.80.33 :
http://www.aaa-replica.com/Omega_4632.80.33.html
Omega DeVille Co-Axial Power Reserve Mens Watch 4532.40 :
http://www.aaa-replica.com/Omega_4532.40.html
Omega DeVille Co-Axial GMT Mens Watch 4533.51 :
http://www.aaa-replica.com/Omega_4533.51.html
Omega DeVille Co-Axial GMT Mens Watch 4533.50 :
http://www.aaa-replica.com/Omega_4533.50.html
Omega DeVille Co-Axial GMT Mens Watch 4533.31 :
http://www.aaa-replica.com/Omega_4533.31.html
Omega DeVille Co-Axial Chronograph Mens Watch 4541.50 :
http://www.aaa-replica.com/Omega_4541.50.html
Omega DeVille Co-Axial Mens Watch 4531.51 :
http://www.aaa-replica.com/Omega_4531.51.html
Omega DeVille Co Axial Mens Watch 4531.50 :
http://www.aaa-replica.com/Omega_4531.50.html
Omega Speedmaster Mens Watch 3211.31 :
http://www.aaa-replica.com/Omega_Speedmaster_Mens_Watch_3211_31.html
- 11
- Max size for upload...Hi guys,
i've a simple question for you.
I'm developing a jsf application that allows to user to upload a file
into a mysql table.
I'm using Jakarta project to perform upload.
Everythings go well until a maxsize is reached, after i have
error......
how can i set this maxsize?
Can i change it?
How?
Thanks....
- 12
- Linking hibernate ejb3 persistence unitsI know the EJB3 spec supports linking beans belonging to separate
persistence units at deploytime, but I'm not sure if the Hibernate
implementation supports this. Does anyone know how to do this? Any
good documentation or examples?
Thanks in advance
- 15
- it seems like my scene is empty :(I'm a beginner. I know nothing more than I read in some tutorials. So
pelase be patient and forgiving ;-)
So when I try to construct the scene, the only thing I see is black and
probably empty area :( My code is similiar to what I've seen in those
tutorials but it simply isn't working, while the examples I tried gave
good results. This is code of my createScene function:
meshX and meshY are constants. int intensity[][] keeps values of y
coordinates. These values can generally be anything between 1 and 255.
public BranchGroup createScene()
{
TransformGroup tg = new TransformGroup();
BranchGroup objRoot = new BranchGroup();
TriangleArray tri;
for(i=0;i<meshX-1;i++)
for(j=0;j<meshY-1;j++)
{
tri = new TriangleArray(3, TriangleArray.COORDINATES);
Shape3D shape = new Shape3D();
tri.setCoordinate(0, new Point3f(i+1, intensity[i+1][j], j));
tri.setCoordinate(1, new Point3f(i, intensity[i][j], j));
tri.setCoordinate(2, new Point3f(i, intensity[i][j+1], j+1));
shape.setGeometry(tri);
tg.addChild(shape);
Shape3D shape2 = new Shape3D();
tri = new TriangleArray(3, TriangleArray.COORDINATES);
tri.setCoordinate(0, new Point3f(i+1, intensity[i+1][j+1],
j+1));
tri.setCoordinate(1, new Point3f(i+1, intensity[i+1][j], j));
tri.setCoordinate(2, new Point3f(i, intensity[i][j+1], j+1));
shape2.setGeometry(tri);
tg.addChild(shape2);
}
Transform3D cc3d = new Transform3D();
cc3d.setTranslation(new Vector3f (0f ,0f ,10f ));
tg.setTransform(cc3d);
objRoot.addChild(tg);
return objRoot;
}
can you help me?
Marcin
- 15
- Ant API - Examples where? Please help.Hi all,
I need to develop a series of classes (zip, unzip, ftp, scp, rsh and
ssh) in java using the Ant API.
But I can't find anything on this, any tutorials, any example code.
I've searched the net, many books and I got almost nothing. Java
source code i only get the "How to develop an Ant Task" thing.
Does anyone know where can i get simple examples of using this in
java?
Thank you all.
|
| Author |
Message |
TheBigPJ

|
Posted: 2008-2-28 20:15:00 |
Top |
java-programmer, New technology, old idea.... why not?
Good Morning/Evening,
I'm young and foolish but love to create new ideas. The one I am
currently pondering...... (a simple unoptermised version of it):
public void wastefulSort()
{
//Using todays technology, of a lot of unused space
int[] A = {5,4,3,2,9};
int[] B = new int[1000];
for(int i = 0; i < A.length; i++)
{
B[A[i]] = A[i];
}
}
Assumptions:
This is run on a turing machine.
The input values do not repeat.
Assume any B space unused, it is null (not 0).
-------------------------------------------------
Is this not the quickest way of sorting numerical data? aka takes n
(or O(n))?
Thanks,
Peter
|
| |
|
| |
 |
Florian Huebner

|
Posted: 2008-2-28 21:12:00 |
Top |
java-programmer >> New technology, old idea.... why not?
TheBigPJ wrote:
> Is this not the quickest way of sorting numerical data? aka takes n
> (or O(n))?
The problem: Retrieving the data is very slow
|
| |
|
| |
 |
TheBigPJ

|
Posted: 2008-2-28 21:26:00 |
Top |
java-programmer >> New technology, old idea.... why not?
On 28 Feb, 13:12, Florian Huebner <email***@***.com>
wrote:
> TheBigPJ wrote:
> > Is this not the quickest way of sorting numerical data? aka takes n
> > (or O(n))?
>
> The problem: Retrieving the data is very slow
Logically that makes sense yes.
But is that actually an attribute (if you like) of sorting data? aka
sorting is really 'Sorting and Retrieving'?
Peter
|
| |
|
| |
 |
TheBigPJ

|
Posted: 2008-2-28 21:31:00 |
Top |
java-programmer >> New technology, old idea.... why not?
And if you count retrieving as part of this, then searching the data
will take 1 move?
So the simple trade off, of displaying all the data takes a long time
is justified by only taking 1 move to search?
Or is this not the case?
Peter
|
| |
|
| |
 |
Ulrich Eckhardt

|
Posted: 2008-2-28 21:46:00 |
Top |
java-programmer >> New technology, old idea.... why not?
TheBigPJ wrote:
[...sorting...]
> //Using todays technology, of a lot of unused space
> int[] A = {5,4,3,2,9};
> int[] B = new int[1000];
>
> for(int i = 0; i < A.length; i++)
> {
> B[A[i]] = A[i];
> }
[..]
> Is this not the quickest way of sorting numerical data? aka takes n
> (or O(n))?
This is indeed pretty fast. There is a variation of the same:
B[A[i]] += 1;
i.e. you simply count the number of times the integer occurred, then you can
also use e.g. zeroes.
Drawbacks:
- the range must be known
- the number of elements in the range must be finite
- the range should be small
because this information is needed to dimension the counter array ('B' in
this case). Note: with a not-so small range or with unknown range you can
still use a tree instead of an array, but then the algorithm degrades
accordingly.
> Assumptions:
> This is run on a turing machine.
Why not on a computer? ;^)
Uli
--
Sator Laser GmbH
Gesch盲ftsf眉hrer: Michael W枚hrmann, Amtsgericht Hamburg HR B62 932
|
| |
|
| |
 |
Eric Sosman

|
Posted: 2008-2-28 21:53:00 |
Top |
java-programmer >> New technology, old idea.... why not?
TheBigPJ wrote:
> Good Morning/Evening,
>
> I'm young and foolish but love to create new ideas. The one I am
> currently pondering...... (a simple unoptermised version of it):
>
> public void wastefulSort()
> {
> //Using todays technology, of a lot of unused space
> int[] A = {5,4,3,2,9};
> int[] B = new int[1000];
>
> for(int i = 0; i < A.length; i++)
> {
> B[A[i]] = A[i];
> }
>
> }
>
> Assumptions:
> This is run on a turing machine.
> The input values do not repeat.
> Assume any B space unused, it is null (not 0).
> -------------------------------------------------
>
> Is this not the quickest way of sorting numerical data? aka takes n
> (or O(n))?
First, the idea is not new at all: It's a primitive
version of what is known as an "address calculation sort."
Second, the time complexity is O(A.length + B.length).
Since B.length must be as least as great as the "span"
of the A values, it can turn out to be the dominant term
in the run time. Consider int[] A = { 1, 1000000000 },
for example. Observe that even a two-element A may
require a B that is much longer than Java's maximum
array size.
Third, you'll have a hard time generalizing it to
sort the array double[] A = { 1.2, 1.3, 1.4, -Math.PI }.
All in all, I'd suggest you not invest a whole lot of
effort in "optermizing" this code.
--
Eric Sosman
email***@***.com
|
| |
|
| |
 |
TheBigPJ

|
Posted: 2008-2-28 22:38:00 |
Top |
java-programmer >> New technology, old idea.... why not?
Young
- Thinking sorting was so simple to solve
Foolish
- Used only a small set of data within a small range (should have
remembered that)
- Should have thought outside the 'box' more
Learned
- Have another array then that time is added to the time complexity
- This is called 'address calculation sort'
- The right way to spell "optimized"
Question
- Are we there then on sorting data? At the end? Or just very close
to it?
Thank you all,
Peter
|
| |
|
| |
 |
Daniel Pitts

|
Posted: 2008-2-28 23:18:00 |
Top |
java-programmer >> New technology, old idea.... why not?
TheBigPJ wrote:
> Good Morning/Evening,
>
> I'm young and foolish but love to create new ideas. The one I am
> currently pondering...... (a simple unoptermised version of it):
>
> public void wastefulSort()
> {
> //Using todays technology, of a lot of unused space
> int[] A = {5,4,3,2,9};
> int[] B = new int[1000];
>
> for(int i = 0; i < A.length; i++)
> {
> B[A[i]] = A[i];
> }
>
> }
>
> Assumptions:
> This is run on a turing machine.
> The input values do not repeat.
> Assume any B space unused, it is null (not 0).
> -------------------------------------------------
>
> Is this not the quickest way of sorting numerical data? aka takes n
> (or O(n))?
>
> Thanks,
> Peter
You can handle repeats:
for (int i = 0; i < A.length; ++i) {
B[A[i]]++;
}
This is actually documented many places as a type of sort. It is
definitely space wasteful, and depending on your range and distribution,
can yield a very fast or very slow result. You're example, B could be 8
long, and you could shift the values of A to the range of 0-7 (subtract
the minimum).
However, if A had {2,6,MAX_INT-10}; all of a sudden B has to be
MAX_INT-13 in length, and to *find* the highest value in B, you'd have
to iterate nearly two billion entries (assuming 32bit ints)
To make matters worse, what if you have A be {4, MAX_INT, MIN_INT}
Now, you're indexes into B aren't "int", they would have to be long, and
your memory size would have to be at least 4 gigs of integers (around
16gigabytes)
so, if you know the of A is small, and it is very densely populated,
then you can use this method for a speed increase.
For a general solution where you don't know those details before hand,
O(n*logn) is as good as it gets.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
|
| |
|
| |
 |
Mark Space

|
Posted: 2008-2-29 2:21:00 |
Top |
java-programmer >> New technology, old idea.... why not?
TheBigPJ wrote:
> Good Morning/Evening,
>
> I'm young and foolish but love to create new ideas. The one I am
> currently pondering...... (a simple unoptermised version of it):
>
> public void wastefulSort()
This is a pigeon-hole sort. (I don't know why so many mathematics and
other scientific theories come down to pigeons. I makes me think that
Douglas Adams got things almost right. He just substituted mice for
pigeons by mistake.)
Anyway... pigeon-hole sort:
http://en.wikipedia.org/wiki/Pigeonhole_sort
The next step up is the bucket sort, which actually very useful. See if
you can spot the logic of the follow up.
|
| |
|
| |
 |
Eric Sosman

|
Posted: 2008-2-29 4:54:00 |
Top |
java-programmer >> New technology, old idea.... why not?
TheBigPJ wrote:
> [...]
> Question
> - Are we there then on sorting data? At the end? Or just very close
> to it?
A lot depends on how you formulate the problem. If you
sort using pairwise comparisons and you have no exploitable
prior knowledge of the existing arrangement, then it's not
hard to show that the problem is O(N log N). These are the
assumptions usually made for "general-purpose" sorting, and
one can see why: in Java, it means you can sort anything
that implements Comparable or for which you can build a
Comparator, so the sorting methods don't need information
about the nature of the objects being sorted.
But "special-purpose" sorting is another matter! For
example, if you know that the original sequence is in order
except for possibly one pair of adjacent items, the problem
shrinks down to O(N). Or if you have a way to determine the
order of items without comparing them -- that's what your
method does, more or less -- you may be able to get to an
O(N) sort.
There's even an O(1) sort, which I've always seen explained
in terms of pasta. You've got many pieces of uncooked spaghetti,
and you want to sort them by length. So you pick 'em all up in
a bundle, hold it vertically, and slam one end down on the
counter. Lo! The tallest strand now stands higher than all
the others, and the shortest strand stands lower, and so on
for all the in-betweens. They're "sorted" in just one step,
and with zero comparisons! (Of course, the task of picking
out the strands in sorted order still lies ahead ...)
Finally, big-Oh is not the end of the tale. If I offer
you several O(N logN) sorting methods, would you be expect them
all to take the same amount of time on the same inputs? If you
do, you don't understand big-Oh!
--
email***@***.com
|
| |
|
| |
 |
Roedy Green

|
Posted: 2008-2-29 7:13:00 |
Top |
java-programmer >> New technology, old idea.... why not?
On Thu, 28 Feb 2008 04:15:22 -0800 (PST), TheBigPJ
<email***@***.com> wrote, quoted or indirectly quoted someone who
said :
>I'm young and foolish but love to create new ideas. The one I am
>currently pondering...... (a simple unoptermised version of it):
see http://mindprod.com/jgloss/radixsort.html
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Java apps + autodesk AutocadHi !
I am writing a java application to launch autocad executable (done!) and
send commands (open file, save file) to this autocad executable instance....
anybody here can help me with any links?
thanks in advance
- 2
- Applet paint problem (only on IE)I've written an animated, double buffered graphical applet for JDK 1.1.8 (It
has to run without the user having to download a new JRE) that is run in a
table cell on a web page. It uses threads for the animation, with a delay
based on the speed of the animation.
The problem is that on IE, the image does not display until it regains
focus, ie the page is scrolled down, then up, or a second window obscures it
and is then removed. According to the Java console, it has started fine.
It works as it should on FireFox and Opera, and works in IE when it is the
only thing on the page. I have tried everything I can think of (removing the
delay, extra repaints, trying every kind of embedding into the web page,
etc, even trying to get keyboard focus) but to no avail.
Does anyone know what the problem might be?
Thanks,
Greg
- 3
- Text on the screen , java3dhey mates, im really newbie with java3d, im learning this api, and
doing somes test, but i have my first question, i want to put some
text on the screen, i know its exist a Text2D class, but its interact
with the virtualuniverse , i want only put flat text on the screen,
with some data, maybe the fps , coordenates , etc
i was trying to use the getGraphics of Canvas3D and use drawString but
didnt work, i did the same thing with Frame also with Applet, i got
the graphics and used drawString, but nothing
how can i do to be able to do this? could you give me somes examples?
i hope you can help me:D
PD: sorry my bad english , i from venezuela :$
- 4
- Finding file inside jar or zip fileIf I want to find whether a file test.java exists in my c:\ directory,
I do
File f = new File("c:\test.java");
f.exists();
But if I have that test.java inside a zip file or jar file, how do I
find it's existance? I tried doing
File f = new File("jar:c:/data.zip!/test.java");
f.exists();
It didn't work. It always return false.
Does anyone have any idea on how to find the existance of a file inside
a zip or jar file?
Thanks,
- Raja.
- 5
- Locator2 and SAX parsersHello:
I'm using the org.xml.sax JAVA API to manage a XML file.
I want to know if it exists a SAX parser ( SAX driver ) that supports
Locator2 interface (in org.xml.sax.ext package ).
My objetive is to get the encoding property of a XML file, and that
interface has a getEncoding() method.
Anyone SAX parsers that I've probed don't supports this interface (xerces,
piccolo, oracle , aelfred, ... )
I would like to know if somebody has used this JAVA interface (Locator2).
Thaaaaaanks
- 6
- Create own data structure from DOM?Hi again!
I successfully parsed my XML file into a DOM and traversed it in level-
order. I did that to gather information about component number and
level of each component node in the tree, because I need to work with
that information a little later.
The original XML file looks a little like this (the attribute index
letters represent the level-order "numbering"):
<Component ind="A">
<Component ind="B">
<Component ind="D"/>
<Component ind="E"/>
</Component>
<Component ind="C">
<Component ind="F"/>
</Component>
</Component>
What I'm trying to do now is to create instances of each component. I
have a Component class carrying all information I need - except one:
Who's my father component?
What should I do to tell every component instance of it's father node
without creating more than one instance of each component?
I thought of two and a half possibilities yet, but I really hope you
can help me here or give me some new ideas:
a) put every component node (from DOM) onto a stack and pop one by one
by creating component instances and create another component instance
of node.getParent(). but then I have a lot of component instances
doubled or tripled or even more... that ain't really efficient.
Stack:
F
E
D
C
B
A
b) create instances while traversing the DOM and add each instance to
a array list. But then I have the problem of not knowing the array
index of the father component.
Array:
A B C D E F
c) create multiple lists with array[0] carrying the father node
followed by it's child nodes (array[i])
Array 1:
A B C
Array 2:
B D E
Array 3:
C F
Thank you in advance!
/Chris
- 7
- openoffice.org-2.0 build errorThis is a multipart MIME message.
Is there resolution to overcome this?
hs_err_pid22565.log is attached.
Thanks.
Bob
email***@***.com
- 8
- Maven: Calling ANT scripts before buildHi all,
I have this little problem in maven. I like to call an ANT script which
does some JAXB compiling before my compile goal is executed.
does anyone know how to achieve this? I have looked into the docs, and
I don't quite get it, I fear ... :-) .
Thanks in advance & greetings,
Axel.
- 9
- Launching a browser -- help!I've found several good examples out there on how to launch a web
browser
from a Java application, using the Runtime exec() command. However,
what
I'd like to do is configure the browser that's launched, as one would
in
an html link with the javascript onclick="window.open(
'http://www.mysite.com', 'mywindow',
'width=500,height=500,scrollbars=no,resizable=no')"
Is there any way to set, for example, the width and height on the
browser
I launch? There doesn't seem to be any command line parameters for
the
browser I'm launching, and besides, those would be platform-specific.
I
suspect it will require some javascript trickery -- but I only know
how
to specify those parameters on links, not on the page I'm am newly
invoking...
Please help!
--Mark
- 10
- Help building applicationHello,
I am fairly new to Java. I recently switched from C++ to Java for a
project I am working on. I was looking for a decent HTML parser when I came
across the htmlparser 1.5 project on Sourceforge.net. I understand the
logic, but I am having build problems with my own classes. If I put my class
in the jar file along with all the other parser classes, everything works
well, but I prefer not to do it that was. When I have a separate .class file
and try to run it through the JVM I get the following error:
"java.lang.NoClassDefFoundError: AdamParser (wrong name:
org/htmlparser/AdamParser)". All I want to do is test my ideas the simplest
way possible. I was hoping some more experienced Java programmer could help
me.
TIA,
Adam
- 11
- Change so that I can print .txt or .rtfHi All,
I have tested this program below using a .gif and it works
successfully.
I want to change it so that I can print a notepad.txt or wordpad.rtf.
TIA,
bH
import java.io.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import javax.print.event.*;
public class BasicPrint {
public static void main(String[] args) {
try {
// Open the image file
InputStream is = new BufferedInputStream(
new FileInputStream("BIGbggrn01.gif"));
// Find the default service
DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
PrintService service =
PrintServiceLookup.lookupDefaultPrintService();
// Create the print job
DocPrintJob job = service.createPrintJob();
Doc doc = new SimpleDoc(is, flavor, null);
// Monitor print job events; for the implementation of
PrintJobWatcher,
PrintJobWatcher pjDone = new PrintJobWatcher(job);
// Print it
job.print(doc, null);
// Wait for the print job to be done
pjDone.waitForDone();
// It is now safe to close the input stream
is.close();
} catch (PrintException e) {
} catch (IOException e) {
}
}
}
class PrintJobWatcher {
// true iff it is safe to close the print job's input stream
boolean done = false;
PrintJobWatcher(DocPrintJob job) {
// Add a listener to the print job
job.addPrintJobListener(new PrintJobAdapter() {
public void printJobCanceled(PrintJobEvent pje) {
allDone();
}
public void printJobCompleted(PrintJobEvent pje) {
allDone();
}
public void printJobFailed(PrintJobEvent pje) {
allDone();
}
public void printJobNoMoreEvents(PrintJobEvent pje) {
allDone();
}
void allDone() {
synchronized (PrintJobWatcher.this) {
done = true;
PrintJobWatcher.this.notify();
}
}
});
}
public synchronized void waitForDone() {
try {
while (!done) {
wait();
}
} catch (InterruptedException e) {
}
}
}
- 12
- <<Whats this? >>Help ButtonDear All
In most windows based applications, we can find a button with icon like
[Arrow and Question mark]
It is always on the help menu
When selected the Cursor is changed to that icon, and any thing clicked
will pop-up a small yellow help tip
How can this be done with java?
Thanks ;
Essam
- 13
- Mobile phones, J2ME and Java Enabled Phone
Regarding Mobile Phone and j2me or Java enabled phone I have two
query.
1)I need help on finding a mobile phone that support j2me.
2)How can I download a J2ME application to a mobile phone that support
J2ME or Is a Java Enabled?
Any help is appreciated.
-Reda Mokrane
- 14
- import & jars; adding TestPlugIn.java to JamochaMUD.jarhere are the errors:
---------on FC2 linux------------------------
[thufir@ plugins]$ pwd
/home/thufir/anecho/JamochaMUD/plugins
[thufir@ plugins]$ /usr/java/jdk1.5.0/bin/javac TestPlugIn.java
TestPlugIn.java:3: cannot find symbol
symbol : class JMConfig
location: package anecho.JamochaMUD
import anecho.JamochaMUD.JMConfig;
^
TestPlugIn.java:4: cannot find symbol
symbol : class MuSocket
location: package anecho.JamochaMUD
import anecho.JamochaMUD.MuSocket;
^
TestPlugIn.java:8: cannot find symbol
symbol: class PlugInterface
public class TestPlugIn implements PlugInterface {
^
TestPlugIn.java:10: cannot find symbol
symbol : class JMConfig
location: class anecho.JamochaMUD.plugins.TestPlugIn
JMConfig settings;
^
TestPlugIn.java:12: cannot find symbol
symbol : class JMConfig
location: class anecho.JamochaMUD.plugins.TestPlugIn
public void setSettings(JMConfig mainSettings) {
^
TestPlugIn.java:43: cannot find symbol
symbol : class MuSocket
location: class anecho.JamochaMUD.plugins.TestPlugIn
public String PlugMain(String jamochaString, MuSocket mu) {
^
6 errors
TestPlugIn.java is just cut-and-pasted from
<http://jamochamud.anecho.mb.ca>. (see plugin documentation)
just looking at this error:
TestPlugIn.java:3: cannot find symbol
symbol : class JMConfig
location: package anecho.JamochaMUD
import anecho.JamochaMUD.JMConfig;
the anecho/plugin directory was created by JamochaMUD.jar. do I need to
un-jar everything in order for this import statement to work, or can I
leave the JamochaMUD.jar intact and simply work from TestPlugIn.java in
../anecho/plugin ?
thanks,
Thufir Hawat
- 15
- Design pattern for 1 Producer/multiple Consumers?I'm doing a simple Producer/Consumer thing based on the example in the Sun
docs, where the Consumer does a wait until there is something to consume,
then it consumes it and does a notify, and the Producer does a wait until
there is nothing to consume and then adds it and does a notify. But now I
need a bunch of Consumers. Is there a standard design pattern for this,
or am I going to have to figure it out myself?
--
Paul Tomblin <email***@***.com> http://blog.xcski.com/
Do you have a point, or are you saving it for a special occasion?
-- David P. Murphy
|
|
|