java

How to implement java Authentication in desktop application

Hello all what is the best way to implement AA mechanism ( authorization and Authentication ) in java desktop app , i have accounting application that needs AA mechanism ...

Java : loop on all the classes in the classpath

Is there a way to iterate over all the classes in the classpath ? I want to make some reflective checks on some classes implementing a certain interface, but I want to do it completely dynamically, without any input on which classes to check, just browsing the classpath. ...

how do i build an array in the test class

public static void main(String[] args){ Employee [] employeeList = { // build your list here }; } how exactly do i build my array. the array is just 2 strings that are defined in another class. class Employee { protected String name; protected String jobTitle; Employee(String n, String title) ...

How can I find out where a ResourceBundle came from?

Given a ResourceBundle object, is there a way to get a URL or other indicator as to where it was found when it was looked up? The ResourceBundle is being created with: ResourceBundle rb = ResourceBundle.getBundle("filename"); And it is being loaded from a file subdir/filename.properties, in most cases. I'd like to be able to program...

Java LDAP Management - Using the netscape.ldap package, checking authentication and adding users

I am currently using the netscape.ldap package to handle LDAP Connection and Authentication. I don't know if this is the best framework for LDAP Management but it's what I've got anyways. Using this I really have to check if the user exists or not by doing so obisouly ugly and bad statements, such as followed: try{ conn.connec...

How to combine multiple charts created using JFreeChart API?

Hi All: My requirement is need to display 2 barchart and 3 trendchart in single page. For that, i have used JFreeChart API and sending the image in bytearray format through response. Its working fine for single image. How do i merge all 5 charts and send that through response?. Please help me. Sample Code: chartTypeCode="1...

[Java] Eclipse documentation

I write application in Java(SWT) and I want to add documentation like in Eclipse application. How to do it? Is it exist tools for this? Documentation window in Eclipse: ...

AS3 Date not serializing to Java Date using BlazeDS

When I pass a Actionscript Value Object that contains a Date variable using BlazeDS it is not getting transferring as a java.util.Date object correctly. When the setBaseDatefunction gets called on the Java side the baseDate value is NULL. The weird thing is if I rename the variable on the Java side to private Date date; and create a pu...

Socket inactivity timeout in java

Hi, I can't find in the socket java API a way to close a inactive connection open for TIMEOUT millisecond. The goal is to avoid an embarassing error when I forget to close the socket explicitly (and force the distant resource to be rebooted). If I don't find a low level method, I will add a last-time-used value to our connection, and ...

Multipart Form Submit Directly to an URL

Hi, We've a web-based application wherein there is an option for Users to upload documents / files into our database. Before uploading any document / file, we want to send the file for free online virus scanning offered by few websites like http://virusscan.jotti.org/en, get the scan status from them. Only if the response status is O...

Spring Entity to use Service, possible design flaw, but still....

Hi guys, The legacy database I'm "springwrapping" has Id's that are Strings and that give away some information. For instance, a UserId looks like "DK-6715-00001", meaning a user in Denmark, postal code 6715. This is so wrapped into the enterprise applications that it needs to be kept and my entities verify this in their setter methods....

Figure out method name from line number in Java?

Given a line number, the code file, as well as the compiled class file if necessary, what is the most elegant way to get the signature of the surrounding method (if the line number is even in a method)? Things to keep in mind: the line might not even be in a method the line might be in a method of an inner or anonymous class While...

NIO - Detecting a closed connection

I have written a server that performs non-blocking IO using the Java NIO API. I'm seeing a situation whereby occassionally a client application shuts down abruptly (e.g. due to power loss) and the connection is left open on the server-side. A colleague has encountered the same problem and said he uses heartbeats over the line to detect...

Java: Howto get the thumbnail from a file

Hello, In windows explorer (and linux gnome) views for each file a thumbnail / icon. Like with EXEs, images, videos, txt-files, ini-files and so much other file types. Now is my question: Is there a way to get them by file. Something like: public static BufferedImage getThumbnail(File file) {...} Thanks ...

Does the Java API have a data structure to represent hierarchy

I've got two classes; one interprets commands, and sends these commands to another class which executes them. I then want the class which executes the commands to be able to send the results of this execution back to the interpreter class. The problem is that these results are hierarchal in nature. Right now the only thing I know of i...

Is there a simple way to alphabetize a String Enumeration in Java?

Just as the title says. I tried messing around a bit with Collections.sort() on a List[] and the .sort() function of an ArrayList but I was never able to parse it back to an Enumeration. Thanks! EDIT: Here's some pseduocode and further explanation. My goal is to take the keys() from a Hashtable and do complex operations involving eac...

Is There a Design Pattern to Mimic XML?

I am writing an application in Java that produces a XML file using data obtained through JDBC. This is a recursive one-to-many relationship much like the structure of an XML document. It basically looks like this: Object A contains multiple object B's. Object B contains multiple object C's. And so on. Is there a handy design pattern...

Is there an automated way of transforming Java code with over-long (>64kb compiled) methods?

As I understand it, the JVM has a limit of 64KB of compiled code per method. I have a tool which generates Java code to be run, and sometimes the generated code contains methods which are longer than this. Does there exist an automated way of transforming a Java class file with overly long methods into one which produces the same result...

JPopupMenu Behavior

I prepared a small test case below. My problem is when i right click on the window. JPopupMenu show up but if i click anywhere outside the JWindow menu does not disappear. I have to click somewhere on the window to get rid of it which is not the expected behavior. EDIT: after reading akf's answer i switched to JFrame, when frame is in f...

Why would invokeAll() not return?

I have roughly this code: ExecutorService threader = Executors.newFixedThreadPool(queue.size()); List futures = threader.invokeAll(queue); I debug this and invokeAll doesn't seem to return until all the threads in the Queue are finished. Any reasons why this is happening. ...