java

Display Hibernate Query in JTable

I'm seeking an efficient way to display an SQL table queried via Hibernate in a JTable. Query q = em.createNamedQuery("Files.findAll"); List rl = q.getResultList(); It would probably be preferable to use the List returned by that (In this case, that would make a list of Files objects (where Files is an internal class, not java...

Why isn't there a parallel to Java's setAccessible in .NET?

Take a look at setAccessible - a way in Java to let you call private methods by reflections. Why didn't .NET implement such a feature yet? ...

co. corp. inc. regular expression

This is my first time working with regular expressions and I've been trying to get a regular expression working that would match the following: apple apple inc. apple co. apple corp. but would not match: inc. apple co. apple apple co. inc. apple corp. inc. apple inc. corp. and so on... This is what I got so far (apple)\s(inc|co...

What is the best way to represent a composite key (key containing two values) of a Class and a Boolean

HashMap<Pair<Class<T>,Boolean>,String> abc = new HashMap<Pair<Class<T>,Boolean>,String>(); What is the best way to represent Pair here... Does Java offer anything? My key will always be a {class,boolean} pair. Thanks! ...

Java seems to support volatile fields of type long, while C# does not - What are the reasons behind this?

Can anyone explain to me what the benefits and and drawbacks of the two different approaches are? ...

Web: When should I consider using Java rather than PHP, Python/Django, Ruby/Rails, etc?

If gathering requirements for a medium-to-large web-based project, at what point should one consider using Java-based back-end, JSP, etc, over a scripting language like PHP, Python, or Ruby? Hearing "use the right tool...", when is Java the right tool for web-based projects? ...

Eclipse: How to convert a web project into an AspectJ project and weave and run it using the AJDT plug in?

What I want to do: I want to use the @Configured annotation with Spring. It requires AspectJ to be enabled. I thought that using the AJDT plugin for compile time weaving would solve this problem. Before installing the plug in the dependencies which were supposed to be injected into my @Configured object remained null. What I have don...

Connect to a secure database using JDBC

How do you specify the username and password for a JDBC connection when acessing a secure database? ...

How to add sound recording to a java based website - preferably a open source solution

I need to add functionality to a website to allow users to record a short sound snippet with their microphone. I understand that this is possible with flash - but is there a free solution? Ideally I was hoping this could be achieved without using applets. Does JavaFX or flex provide this functionality? Thanks in advance. ...

How to stream XML data using XOM?

Say I want to output a huge set of search results, as XML, into a PrintWriter or an OutputStream, using XOM. The resulting XML would look like this: <?xml version="1.0" encoding="UTF-8"?> <resultset> <result> [child elements and data] </result> ... ... [1000s of result elements more] </resultset> Because the...

Is there a way to extract the JavaDoc from a single class in NetBeans?

I want to look at the javadoc in html format but do not want it for the entire package, is there some way to do this. ...

composite key v/s 2 levels of indirection

HashMap<Pair<Class<T>,Boolean>,String> abc = new HashMap<Pair<Class<T>,Boolean>,String>(); I have two approaches here... create a key{class, Boolean} -> {string} or i could also do this. {class} -> {Boolean, string} the first approach has 1 level of indirection which the second approach has 2... what are the pros and cons here? Is th...

Matching partial strings for password recovering

I'm trying to think of a regular expression for this but not having any luck.. Let's say you have a security question on you website so the person can recover a password. People often forget exactly how they entered information. For example, given the question "What company do you work for?", a user might answer "Microsoft Corp.". But ...

Java API to convert JPEG to TIFF

I am looking at java APIs to convert JPEG file streams to TIFF files. I looked at the JAI but did not find something similar to what i am looking at. Can someone point me to a good API which does this ? ...

Why the jpg file I converted from a gif file isn't crisp and clear ?

I use the following code to convert a gif file to a jpg file, it works but the result jpg file isn't the same quality as the original gif file, why ? Any way to improve the quality ? try { ImageIO.write(ImageIO.read(new File("C:/abc.gif")),"jpg",new File("C:/abc.jpg")); } catch (Exception e) { e.printStackTrace(); } So, to ask this ...

How to make a perforce branch with a different java package name?

My first instinct is to branch normally (using p4 integrate), and then use an IDE or sed script to change the package names. But this makes future integration from the trunk extremely painful. ...

Estimating a probability given other probabilities from a prior

I have a bunch of data coming in (calls to an automated callcenter) about whether or not a person buys a particular product, 1 for buy, 0 for not buy. I want to use this data to create an estimated probability that a person will buy a particular product, but the problem is that I may need to do it with relatively little historical data ...

Java cannot resolve DNS address from AIX: UnknownHostException.

I'm having this strange error. On AIX, if I can reach my server from the command line ( using ping / telnet ) But If I try using java I've got UnkownHostException This is due to Java cannot somehow "use" the DNS but I don't know why. If I use the IP address it works fine. This is my test program. import java.net.*; public ...

Maven assembly:assembly

Hello I am trying to create a custom descriptor ref in my parent pom which packages all dependencies with sources. I got the assembly.xml nailed down pretty well, but when I add it to my base POM assembly:assembly fails like so: [INFO] [assembly:assembly] [INFO] ------------------------------------------------------------------------ [E...

java xslt tutorial

Can any one suggest good XSLT with java tutorials? ...