java

Java prints output twice in a very specific circumstance

System.out.print("My string: "); My string: BUILD SUCCESSFUL (total time: 1 second) System.out.print("My string "); My string BUILD SUCCESSFUL (total time: 1 second) System.out.print("My string: "); My string: My string: BUILD SUCCESSFUL (total time: 1 second) Printing a string that ends with a colon and two spaces will make...

primitive multimap in java with good (insert, iteration) performance characteristics

I'm doing some heavy processing (building inverse indices) using ints/ longs in Java. I've determined that (un)boxing of standard java.collections maps takes a big portion of the total processing time. (as compared to a similiar implementation using arrays, which I can't use due to memory constraints). I'm looking for a fast 3rd-part...

Is there any way to observe change in Database table through Hibernate?

In my application, I am storing a small table containing 50 records in a singleton class because the data in this table hardly changes - e.g. the list of countries. Although, the concept is not good, I have to continue with it right now. Is there any solution in Hibernate which observe change in the table and on change, invoke a method...

How can I parse XML using Java?

<?xml version="1.0" ?> <input> <sys> <protocol>TL1</protocol> <ipAddress>10.05.2.3</ipAddress> <port>2001</port> <prompt>agent</prompt> <TL1Command> <type>get</type> <command_code>...........</command_code> <staging_block> <tid>...........<...

Checking a number with regular expressions in Java

I have a number "8756342536". I want to check whether the number starts with "8", contains 10 digits all of it is numeric, using regular expression. What pattern would I need for this scenario in Java? Thanks in advance. ...

Adding a watermark to a JTextArea

Is they a way of adding a watermark to a JTextArea? ...

JBoss automatically undeploys EJBs

we have a situation at office. JBoss automatically unloads all deployed EJB's without us knowing why. here's the log we got : 2009-11-09 15:59:51,375 INFO [org.jboss.system.server.Server] JBoss (MX MicroKernel) [4.2.1.GA (build: SVNTag=JBoss_4_2_1_GA date=200707131605)] Started in 14s:704ms 2009-11-09 15:59:51,390 DEBUG [com.ar...

Java SessionID: How to get the Name of the GET SessionID Parameter?

Hello, it seems that the Parameter-Name in the GET request, that represents the SessionID (like jsessionid=XXXXXXXXXXXXXXXXXXXXXXXXXX in Tomcat) is not standardized in the servlet-spec? How can I get the (Servelt Container Specific) name of the SessionID? (At least in Websphere there seems to be the possibilty to change the name of the ...

JFreeChart connecting points in stacked bar charts

Hi, I created a stacked bar chart using JFreeChart (similar to this one). Now I would like to connect the points of the corresponding series for all rows. Is this possible using JFreeChart? ...

Java / Hibernate: Problem with nested object criterias

Hi! I'm having problems with a Hibernate criteria. I'm trying to make a Criteria where I look at the id of a member object of the class the query returns. For example: Criteria crit = session.createCriteria(Enquiry.class) crit.add(Expression.eq("lecture.admin.id", userId)); The result of this is an exception: org.hibernate.QueryExcept...

Jaxb2Marshaller and primitive types

Is it possible to create a web service operation using primitive or basic Java types when using the Jaxb2Marschaller in spring-ws? For example a method looking like this: @Override @PayloadRoot(localPart = "AddTaskRequest", namespace = "http://example.com/examplews/") public long addTask(final Task task) throws AddTaskFault { // do som...

AJAX (prototype/java) getting partial status updates during execution

This partially mimics AJAX (prototype/php) getting partial status updates during script execution, however I'm working with JSP pages and servlets. What I want to do is start an action when the user clicks a button and then present updates on the progress of this action. The action can take anywhere from 1 to 10 minutes to complete, so I...

Unix Script not running in Java using Process Runtime

Hello All... I am developing an application where i required to run some of the scripts of unix from Java Code. Platform i am using is Unix, Tomcat 5.5.. For that, My Sample Code is as follows : Runtime runtime = Runtime.getRuntime(); Process proc = runtime.exec("netstat -i|tail -n +3|cut -d ' ' -f1"); System.out.println("exitValue =...

@IdClass with non primative @Id

I'm trying to add a composite primary key to a class and having a bit of trouble. Here are the classes. class User { private long id; ... } class Token { private User user; private String series; ... } I'm using the orm.xml to map the classes because they're actually part of a higher level API that I don't want to...

How to determine if date/time is EDT or EST in Java?

I have a PDF that users must complete. The PDF has date and time fields on it. The PDF instructs the users to input the date and time in Eastern format (Not EST or EDT). When the user completes the PDF they then generate XML from the PDF and and upload the XML to a Java application. The issue here is that the users may enter the time in ...

Automatic filling entity properties

Hello everybody I have some type an architect(?) question I develop an application, based on Spring and Hibernate (annotated configuration) For each table in my database I added 4 fields: createdBy and modifiedBy(String), created and modified (Datetime). Respectively each entity class also has this fields and getter/setter pairs. So I...

Why is java.lang.CharSequence designed as an Interface?

Hi, Why is CharSequence from the Java API an interface? What is the significance of this interface? ...

File paths in Java (Linux)

I have created a Java application that loads some configurations from a file conf.properties which is placed in src/ folder. When I run this application on Windows, it works perfectly. However when I try to run it on Linux, it throws this error: java.io.FileNotFoundException: src/conf.properties (No such file or directory) ...

In swing GUI how to show a JPanel as maximized when the user clicks a button ?

Hi, I want to maximize a JPanel inside a JFrame when the user clicks a button.What is the best way to achieve this.The view and the data model should be in sync in both the panels,that is the panel which in the JFrame and the maximized one.Please suggest me some solution. my requirement is: i have a JFrame with 4 JPanels named as JP...

Disable default ALT key action in JFrame under Windows

I would like to let my JFrame under Windows not act upon an ALT key press. To clarify, when you execute the following snippet of code: import javax.swing.*; public class FrameTest { public static void main(String[] args) throws Exception { JFrame frame = new JFrame(); frame.setSize(400, 400); frame.setDefaul...