java

Connecting to a MySQL database.

How do I connect from Java to a MySQL database? The Java is run on a local machine while the Database is on a server. ...

How to run findbugs automatically in maven on install

It's easy to add the findbugs plugin to maven so that it will run if I do mvn site However, I would like it to run whenever I do mvn install just like unit tests. That is, I don't want the install to succeed if findbugs finds any bugs. Is there are way for me to do this? ...

Save Java frame as a Microsoft Word or PDF document?

I am working on a billing program - right now when you click the appropriate button it generates a frame that shows the various charges etc, basically an invoice. Is there a way to give the user an option of saving that frame as a document, either Microsoft Word, Microsoft Works or PDF? ...

timeout with JMAPI???

I am using JM-API for my mailing application. When, i am sending or receiving a single mail, works perfectly. But, if i try to do manipulation on more then single mail (say, copy 1st 3 mails of INBOX to TRASH), timeout occurs. While googling to cure this, i got, 1 [see, 2nd last post by vivek mathur] , 2 and 3. But nothing seems to ...

Create a global Robot variable without throwing AWTException

I'm trying to create a global Robot variable in a java class without throwing AWTException. The only way that I can come up with it is by throwing the exception. The reason I need it to be global is because I need to use the same Robot variable in other methods in the class. public class Robo{ Robot r; public Robo() t...

Geting the IP Address Of A client For a webservice

I am using JAX-WS and I am having trouble retrieving the client information that is consuming a webservice. I've found out how to do it with JAX-RPC, and Apache Tomcat Axis, but not with JAX-WS. Does anyone have an idea about this? ...

Newb problem getting typeof in Java

Sorry, I'm a Java newb. I'm trying to figure out whether a number is a Double with something like this: if ( typeof ( items.elementAt(1) )== Double ) { sum.add( i, items.elementAt(1)); } Would appreciate if someone could tell me how to rearrange the syntax to make this work properly. ...

Google App Engine, JDO, and equals/hashCode

I've got an app in Google App Engine that was working fine. I realized that one on of my JDO-enhanced objects that I forgot to implement equals and hashCode (I need to use the object in a set). So I did. I didn't really do anything special in these implementations, in fact I just used Eclipse to generate them. Like so: @PrimaryKey @Pers...

Image referencing in CSS with Wicket

Per a great answer from another question I have begun mounting global resources (css/js/images) in the init() method of my WebApplication. Using the following: mountSharedResource("/images/edit-btn.gif", new ResourceReference(GlobalResource.class, "edit-btn.gif").getSharedResourceKey()); This of course allows css in another package to...

What does portlet programming in java can offer to us?

Hi all, even i do search in google, and read some of the article, but i still not clear what portlet in java can do for us (english is not my native language, sometime is hard to totally understand what people wrote) i was discussing with my friend between java and php. most of the php forum, they allow user to install forum plug-in o...

Source Control Tutorials for Implementing them on C#, Java Developments.

Hi, As a one-man-company taking custom-development jobs (a.k.a. Gun For Hire), the later more complex than the earlier, I'm finding myself in the situation I do really NEED to improve my practices in order to keep the pace and be able to bring more people to work on taks of completing prototypes, making tests, etc. My question is: Wher...

Jasper report exports empty data in PDF format when there is more data

I have a report to be exported in excel, pdf and word using jasper reports. I use xml file as the DataSource for the report, but when the data increases jasper report exports empty file in only for PDF format, when i reduce the data content it export the data available correctly. is there any limitation to pdf size? , how can we manage t...

Java Inner-Class direclty implemented with Parameter Constructor?

Hello, normally I implement my Runnables as follows (directly implemented inner class): Runnable updateRunnable = new Runnable() { public void run() { } } Is there any working way in Java to implement the Class by passing any parameters in the constructor as follows? Runnable updateRunnable = new Runnable(locale) { Lo...

How to generate an *exact* copy of an XML document with resolved entities

Given an XML document like this: <!DOCTYPE doc SYSTEM 'http://www.blabla.com/mydoc.dtd'&gt; <author>john</author> <doc> <title>&title;</title> </doc> I wanted to parse the above XML document and generate a copy of it with all of its entities already resolved. So given the above XMl document, the parser should output: <!DOCTY...

implementing GAE XMPP service as an external component to an existing XMPP server (e.g. ejabberd or OpenFire)

may i know what integration technique that you folks use to implement external component to an existing XMPP server (e.g. ejabberd or OpenFire) . Is it through sending xmpp message to another user@externaldomain directly or using mechanism like urlfetch? ...

Java Keystroke catchining directional keys

Hi, I am catching keys for bindings, so far most characters work fine, until I reached the directional keys (up down left right) My code for catching other keys are: KeyStroke key_3 = KeyStroke.getKeyStroke("3"); How do I catch the directional keys? Thanks! ...

Select string with comma (regex)

I need an regular expression which matches the following: '"test foo bar", "test"' => no match '"test, foo bar", "test"' => "test, foo bar" '"test, foo bar"' => "test, foo bar" '"test foo bar"' => no match '"test", "test, foo"' => "test, foo" '"test", ","' => no match '"test", 0, 0, "foo"' => no match the regex should match any string...

Dynamically creating asynchronous message queues in Java

I need to create asynchronous message queues dynamically in Java. My use case is sending email via multiple SMTP servers: I need to enforce that emails to the same SMTP server are processes sequentially, but emails to different SMTP servers may be processed concurrently. I've used JMS in the past, but as far as I can see it only allows f...

What's the most elegant way to concatenate a list of values with delimiter in Java?

I have never found a neat(er) way of doing the following. Say I have a list/array of strings. abc def ghi jkl and I want to concatenate them into a single string delimited by a comma as follows: abc,def,ghi,jkl In Java, if I write something like this (pardon the syntax) String[] list = new String[] {"abc","def","ghi","jkl"}; Str...

Duplicate elements in java.util.Set

java.util.Set implementations removes the duplicate elements. How are duplicates elements deleted internally in a java.util.Set?? ...