java

Distributing a Java console program

I have created a Java console application using Netbeans. In the Netbeans dist directory I have the class file of the project. Now I need to give the executable files to someone else who will run them on another PC. Which file I should send? How can he run them on his PC? Is there any way to create an exe type file? Both PCs have t...

Deadlock on a single java semaphore?

In one of my recent answers, I gave a theoretical semaphore example of limiting access to memory resources: public static byte[] createArray(int size) throws InterruptedException { semaphore.acquire(size); return new byte[size]; } public static void releaseArray(byte[] array) { semaphore.release(array.length); } I think th...

Java Developer Interview Question

I worked at a fortune 500 insurance company for almost 2 years. I worked on a reporting application that used Java, XML, XSLT, JavaScript, AJAX. It was a J2EE application but it didn't use any of the major frameworks like Struts, Spring, EJB, any ORM, JAXP, JAXB. But we developed our own software in house that could do that stuff. But ...

JNA undefined symbol

Hello, I'm trying to bind the dhcpctl library to Java using JNA. This is mi code (I didn't declare all the functions yet): package com.abiquo.abicloud.omapi; import com.abiquo.abicloud.omapi.DHCPControlStructure.DHCPCtrlDataString; import com.abiquo.abicloud.omapi.DHCPControlStructure.DHCPHandle; import com.abiquo.abicloud.omapi.Omapi...

java static hashmap memory problem

I have 2 classes, let's call the class A and class B. public class A{ private static HashMap<String,B> isc= new HashMap<String,B>(); public static void UserDisconnected(String key){ if(isc.containsKey(key)){ if(isc.get(publicSID).timer != null){ isc.get(key).timer.cancel(); isc.get(key).timer=null; } isc....

Is there a tool which creates C header files for Delphi (Win32) DLLs?

Until now I have seen only tools and some information for the creation of Delphi code for a given C header file. However, in the 'Delphi first' case, there is a Delphi interface declaration and a generated DLL, and no C header. Are there tools which can extract the necessary information and build a C header file for a DLL? Such a tool ...

How to disable redirection to login page in JBoss, when the session expires?

I'm using JBoss AS 5 and JSF+Seam for my web application. I'm using FORM authentication and have defined the login page in "login-config" tag in web.xml file. I also have a filter which will check for the session expired condition and redirect the user to a session_timed_out page. Now the issue I'm facing is that when the session expir...

Java Frameworks that support Entity-Attribute-Value Models

I am interested in developing a portal-based application that works with EAV models and would like to know if there are any Java frameworks that aid in this type of development? salesforce.com uses EAV and currently has twenty tables. The framework I seek should allow it to be configurable to different EAV implementations ...

testing dao with hibernate genericdao pattern with spring.Headache

Hello good fellas! in my journey of learning hibernate i came across an article on hibernate site. i' learning spring too and wanted to do certain things to discover the flexibility of spring by letting you implement you own session.yes i don't want to use the hibernateTemplate(for experiment). and i'm now having a problem and even the t...

Help with a reusable JPA transaction method w/ rollback

I am retro-fitting transaction rollback support to a JPA-based java application, and am using Ecmel Ercans's approach to handling rollback (http://weblogs.java.net/blog/davidvc/archive/2007/04/jpa_and_rollbac.html) and JPA's kinks connected to rollbacks. It looks something like this: EntityManager em = emf.createEntityManager(); EntityT...

Can I make a struts based portlet remember its view when another portlet is used?

I've written a fairly basic portlet using the struts portlet bridge and deployed it to liferay, navigation within my portlet seems fine, but whenever I click a link on another portlet in the portal my portlet reverts to the view action setup in my portlet.xml rather than re-rendering the existing state. What am I doing wrong? My portlet...

What is the list of valid @SuppressWarnings warning names in Java?

What is the list of valid @SuppressWarnings warning names in Java? The bit that come between the ("") in @SuppressWarnings(""). ...

Java Raw Type and generics interaction

If I have a Stack class class Stack<E> {} now if I do: 1) Stack<Integer> s = new Stack() 2) Stack s = new Stack<Integer>() 3) Stack s = new Stack() can anyone explain me what these interactions (generic<->raw) causes? Mainly my doubt is on point 1. In fact if I do that the assignment it's unsafe because that stack can store type...

Sorting a collection of objects

If I have a simple list of Strings: List<String> stringList = new ArrayList<String>(); I can sort it with: Collections.sort(stringList); But suppose I have a Person class: public class Person { private String name; private Integer age; private String country; } And a list of it: List<Person> personList = new ArrayList<...

How to get the project name in eclipse?

How do I get the name of the current eclipse project? I'm in a GMF view and need the projectname when some submenu of the popup menu ist used. ...

Using Java's Graphics or Graphics2D classes, how do I paint a String?

I have a String and I want to paint it onto an image. I am able to paint points and draw lines, however, even after reading the Text part of the 2D Graphics tutorial, I can't figure out how I can take a String and paint it onto my drawing. Unless I'm looking at the wrong tutorial (but it's the one I get whenever I search for anything ab...

Force Singleton Pattern on a Class implementing an Interface.

I better explain the question with an example. I have an Interface Model which can be used to access data. There can be different implementations of Model which can represent the data in various format say XMl , txt format etc. Model is not concerned with the formats. Lets say one such implementation is myxmlModel. Now i want to force m...

Patterns for deploying layered business applications written in Java

I'm working on a layered business application written in Java that should be packaged as an EAR file and deployed to a JBoss application server. There's a web-application layer, a service layer, a domain layer but no persistence layer. At least on paper. What is the best practice for deploying the different layers? In our team we have a...

How handle cache misses: NotFoundException, contains() or `if (null == result)`?

Maybe this is slightly academic, but if I implement a cache for speeding up an application, how should I best handle cache misses? (In my case, the language would be Java, but maybe the answer can be more general.) Throw an exception: ResultType res; try { res = Cache.resLookup(someKey); } catch (NotFoundException e) { res = Ca...

Hibernate/Spring3: could not initialize proxy - no Session

Hi guys, I'm new at Spring, so I put Spring 3.0M3 on a Tomcat server on my Mac, made an Eclipse project, completed a Hello World and then wanted to make an object persist with Hibernate. I've made a User table on my MySQL server, made a User object with all getters and setters (I really wish Java would take a queue from Objective-C here ...