java

Java: Exceptions

Hi, Why is this code correct: try { } catch(ArrayOutOfBoundsException e) { } and this wrong: try { } catch(IOException e) { } This code is wrong because in the try-body never an IOException is thrown, but in the first body there is also never throw a ArrayOutOfBoundsException. And the first code-piece is correct. Why?? Can I ...

Joda Time gives wrong time zone

I'm using the Joda time (1.6) libraries and it keeps returning DateTime objects with the wrong time zone, British Summer Time instead of GMT. My Windows workstation (running JDK 1.6.0_16) thinks it's in GMT and if I get the default time zone from the JDK date/time classes it is correct (GMT). I get the same behaviour on our Linux server...

Global keylogger in Java

I'm writing an application which monitors the person’s mouse and keyboard. If they have not used the keyboard or mouse for 1 minute, it should pops up a message which says “You have not used the mouse or keyboard for 1 minute” and an OK button. How do I do this in Java? ...

eclipse workspace is closed problem

Hi How to get access to eclipse workspace from java program. When I use IWorkspace workspace = ResourcesPlugin.getWorkspace().getRoot() it gives me exception like this java.lang.IllegalStateException: Workspace is closed. at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:329) at amdocs.amsp.test.EMFCod...

Cucumber and/or RSpec with pure Java application using JRuby

After doing some stuff in Ruby on Rails with Cucumber, RSpec and Ruby BDD in general, comming back to JUnit in my Java apps feels like incredible pain to me. I just love the convenience that Ruby brings into testing. From what I understand, it should be theoreticaly possible to use Cucumber features, or even RSpec mocking with pure Java...

is there any library to deserialize with python which is serialized with java.

is there any library to deserialize with python which is serialized with java. ...

java and memory layout

Hey guys, I'm reviewing some questions but I can't really figure it out, i looked through the text book but i'm not sure where i can find answer... I know it would be quite hard to do memory diagrams w/o pictures but please bear with me. interface Lovable public void love(); class Foo implements Lovable public void love(); ...

How do I annotate a JAXB property to use xsd:time rather than xsd:datetime?

I have a JAXB class like this: public class Game { private Date startTime; @XmlElement public Date getStartTime() { return startTime; } public void setStartTime(Date startTime) { this.startTime = startTime; } } which results in an .xsd where startTime has type xsd:datetime. I want it to be xsd...

Problem with JEditor Pane while resizing the frame

Hi , i am new to java GUI programming. i am adding a JEditor pane (with HTML text ) inside a JScrollPane and added the scroll pane to a JFrame.The problem is when i re size the frame the JEditor pane vanishes. Any one help me ? Hi All , Following is the code : here another problem is i set weightx and weighty for the pane .But still ...

SpringFramework JdbcTemplate RowMapper

Hi, I am wondering if JdbcTemplate and RowMapper supports complex object retrieval. I couldn't find anything with google on this matter (Wrong criteria?). :( Example: public class Person() { private Long id; private String name; private PersonDetail personDetail; } public class PersonDetail() { ... } Tables will loo...

java regex search ?

Hi i need to search a string with in paragraph .Here the string may be a java regex . How do i differentiate a regex and a ordinary string. Please give some suggestions to achieve this? ...

What really Filter stream do?

Why does the filter stream used and where? I read that filter streams will be used for letting the needed information into the stream.. Is that right and if so how we can filter from the stream and where exactly it will be used?? java.io.Filter.... My problem here is its very hard to understand why we are using the Filter streams, Sinc...

How do i create a java sandbox?

I want to make my application to run other people's code, aka plugins. However, what options do I have to make this secure so they don't write malicous code. How do I control what they can or can not do? I have stumbled around that JVM has a "built in sandbox" feature - what is it and is this the only way? Are there third-party Java lib...

Java PropertyChangeSupport does not fire for different properties

Hey, I have developed an own javaBean for Swing. Now I'm trying to catch two properties on change, using a PropertyChangeListener. The problem is that the PropertyChangeSupport for one of my properties in the JavaBean works fine but it does not seem to fire any propertyChange for the other declared property. Let me give you some extra...

How to determine active panelBarItem in RichFaces

Hi! I am using the RichFaces panelBar and would like to determine the active panelBarItem at any given point in time. Could you suggest a way of doing so? Thanks in advance! MD ...

Java: accessing transient object fields inside class

Accessing private transient object fields from any method in class must be controlled with some code. What is the best practice? private transient MyClass object = null; internal get method: private MyClass getObject() { if (object == null) object = new MyClass(); return object; } // use... getObject().someWhat(); o...

how to define an inverse cascade delete on a many-to-one mapping in hibernate

I have two classes A and B. Many B's can have association with a single A, hence a many-to-one relationship from B to A. I've mapped the relationship like: <class name="A" table="tbl_A"> <property name="propA" column="colA"/> </class> <class name="B" table="tbl_B"> <property name="propB" column="colB"/> <many-to-one name="a" class...

Testing simultaneous calls to transactional service

How should I test a service method that is transactional for its simultaneous use (it updates a database row by decreasing a value)? I have setup a JUnit test class with SpringJunit4ClassRunner and components are @autowired. Just spawning threads which would call the method doesn't seem to work. I'm not sure whether this has something ...

How do I increase allocated memory in jvm for Grails commands on IntelliJ IDEA 9 Beta ?

I use Windows Vista , 4GB RAM , Core2 I have tested with this idea.exe.vmoptions : -Xms64m -Xmx512m -XX:MaxPermSize=256m -ea -agentlib:yjpagent=disablej2ee,disablecounts,disablealloc,sessionname=IntelliJIdea90 ...

Client.Error.MessageSend problem with Flex/BlazeDS on JBoss

I'm developing a Flex 3.4 app that interops with a Java EE backend running on a JBoss-4.2.2 server, through the most recent release of BlazeDS. When I ran the Flex app from Flash Builder 4 beta 2 on Tomcat, everything was fine, the Flex app was able to make the remote call needed. But my production environment is on JBoss, and when I mov...