java

Which method is used to get mail ids given in CC and BCC list in JavaMail?

Hi to all, I have created a java mail program to send mails. I have doubt regarding which method is used to get mail id which is given in CC and BCC list?. For To list i have used the below code. Code : MimeMessage mime = new MimeMessage(session); mime.addFrom(bean.getFromAddress()); ...

Why would Java classloading fail on Linux, but succeed on Windows?

I've got a Java web application (using Spring), deployed with Jetty. If I try to run it on a Windows machine everything works as expected, but if I try to run the same code on my Linux machine, it fails like this: [normal startup output] 11:16:39.657 INFO [main] org.mortbay.jetty.servlet.ServletHandler$Context.log>(ServletHandler.java...

Network Programming: to maintain sockets or not?

I'm currently translating an API from C# to Java which has a network component. The C# version seems to keep the input and output streams and the socket open for the duration of its classes being used. Is this correct? Bearing in mind that the application is sending commands and receiving events based on user input, is it more sensibl...

Finding closest number in an array

in an array first we have to find whether a desired number exists in that or not? if, not then how will i find nearer number to the given desired number in java. ...

parsing XML that contain XML in elements, Can this be done.

I have a 'complex item' that is in XML, Then a 'workitem' (in xml) that contains lots of other info, and i would like this to contain a string that contains the complex item in xml. for example: <inouts name="ClaimType" type="complex" value="<xml string here>"/> However, trying SAX and other java parsers I cannot get it to process th...

Why avoid the final keyword?

In java, is there ever a case for allowing a non-abstract class to be extended? It always seems to indicate bad code when there are class hierarchies. Do you agree, and why/ why not? ...

XY Layout JAVA

Hi, is there any sort of XY-Layout to Java? So I can set a Button at the X and Y cordinate and that it is suppose to be that big etc.... Because this border layout and grid and panel thing is driven me crazy. :) They are flowing every were and getting strecht up. And to make them small you have to put panel in panel in panel in panel...

Oracle connections in Spring

I am using Oracle 9 JDBC Thin Driver - the connection string I have used for standard JDBC was: jdbcConn.connect("jdbc:oracle:thin:myDevDb/myDevDb@fooServer:1521:MYSIDNAME"); ...just trying to get my head around using this kind of connection in Spring 2.5. How do you wire up Spring to an Oracle connection - think it has something t...

Doubt in build.xml file in Apache-Ant1.6.5

Hi to All : I have used Collections in my code with Generics. When try to compile that java file in build.xml, its showing error at generics and its saying its not a statement. I am using Apache-Ant-1.6.5 and i have installed JDK 1.5 only . I know generic will support in jdk1.5 but its showing error. The below is the error i am getting ...

Cosine similarity of vectors

Hi how do i find the cosine similarity between vectors. I need to find the similarity to measure the relatedness between two lines of text.Can someone help me with the code.what java classes and methods to use. For example i ve two sentences like 1.system for user interface and 2.user interface machine and their respective vectors afte...

Need info on SAML 2.0

For web based Single Sign On (SSO) We need to implement as per SAML2.0 Starndard specification. Would appreciate if any one provides some info on how to use OpenSAML2.0 using JDK 1.4 ...

Can you find all classes in a package using reflection?

A beginner question about reflection, I suppose: Is it possible to find all classes or interfaces in a given package? (Quickly looking at e.g. Package, it would seem like no.) ...

Servlet long processing cancelation when browser closes.

Hi, I have a servlet which processes a request for a long time. It suppose to keep doing stuff in the loop inside doPost and send data through response's out writer. Effectively that continuously appends data in the clients browser . But the problems accures when client just closes the browser. Inspite of the broken connection the respo...

How to read the web.xml from a WebApp

For WebApps, web.xml can be used to store application settings. How can I read this file. My servlets run in a GlassFish v2 server. ...

Why do some claim that Java's implementation of generics is bad?

I've occasionally heard that with generics, Java didn't get it right. (nearest reference, here) Pardon my inexperience, but what would have made them better? ...

Connection pooling options with JDBC: DBCP vs C3P0

What is the best connection pooling library available for Java/JDBC? I'm considering the 2 main candidates (free / open-source): Apache DBCB - http://commons.apache.org/dbcp/ C3P0 - http://sourceforge.net/projects/c3p0 I've read a lot about them in blogs and other forums but could not reach a decision. Is there any relevant altern...

What should be considered using subselects in queries with haevy loaded databases?

We are developing an application with a persistence layer using OpenJPA1.1 and an Oracle DB as backend storage. I will use queries with subselects (see my question at Solving JPA query finding the last entry in connected list). Now my colleagues at work remark, that such queries can lead to performance problems as the database is fille...

Event handling with Jython & Swing

I'm making a GUI by using Swing from Jython. Event handling seems to be particularly elegant from Jython, just set JButton("Push me", actionPerformed = nameOfFunctionToCall) However, trying same thing inside a class gets difficult. Naively trying JButton("Push me", actionPerformed = nameOfMethodToCall) or JButton("Push me", action...

Passing a work item between threads (Java)

I have two threads. The producer is producing pieces of data (String objects), where the consumer processes these strings. The catch is that my application only needs the most recent data object to be processed. In other words, if the producer managed to produce two strings "s1" and then "s2" then I want the consumer to process only "s2"...

Hibernate's setFirstResult() issue with Oracle jdbc driver

I'm trying to do pagination with Hibernate using setFirstResult() and setMaxResults() but I'm not getting the expected results when setting the first result to 0. When doing the following: Query query = session.createQuery(queryString); query.setFirstResult(0); query.setMaxResults(30); List list = query.list(); //list.size() r...