java

Jar file dependencies in Java 1.4

I'm working on a small Java project that now connects to a MS SQL Server 2000 database, but will be shortly connecting to MS SQL Server 2005 database. I'm creating a single jar for ease of deployment. I was trying to set it up so I could just change a configuration file and change drivers (as I would in .NET). However, because of the ...

Overlay multiple JSliders in Swing

Is it possible to overlay multiple JSliders so I can see the "thumbs" on both (I've tried disabling the painting of the track and setting opacity to false but one still hides the other)? Basically I'd like to create a component that allows the user to define a range (and I didn't really want to write a custom one since it has most of the...

Prevent java from localizing SimpleDateFormat output

Basicaly I want to format a Date object using a specific pattern and the output should be in English. How can I prevent java from translating the output in the system language? String date = new SimpleDateFormat("EEE MMM dd kk:mm:ss yyyy").format(myDate); // output is in German: // Mi Aug 26 16:35:55 2009 ...

hibernate workflow

Hi I'm trying to write a program with Hibernate. My domain is now complete and I'm writing the database. I got confused about what to do. Should I make my sql tables in classes and let the Hibernate make them Or create tables in the database and reverse engineer it and let the hibernate make my classes? I heard the first optio...

Java import confusion

What is the difference between: java.awt.*; and: java.awt.event.*; I find both in many programs. ...

How to Client side printing Crystal Report on Java Web Application not with PDF ?

Hi guys, I am looking for solution for client side printing from our java web application JSF/JSP. Rightnow we are using Crystal Report XI R2, and exported to PDF then displayed on client side. The downside with this PDF approach is user will be able to SAVE the PDF and reprint again later. We want to disable the capability to SAVE th...

ant deploy problem

I am working on a spring project. I use ant to deploy application and STS (eclipse based) IDE to develop. I set the CATALINA_HOME environment variable echo $CATALINA_HOME /home/username/springsource/apache-tomcat When I run the deploy ant task from IDE it deploys to a folder under /home/username/workspace/myproject/${env.CATALINA...

Why is Java caching my app while trying to develop it

Hi, i'm trying to build a Java applet and i'm having a major problem trying to set up my development environment because my applet has bugs in it but I can't fix them easilly because Java won't get the latest version of the applet. I've turned off caching in "Java Preferences.app". I want to set it so that applet wil not be cached at al...

Try-catch-finally and then again a try catch

I have often come across situations like :- try{ ... stmts ... } catch(Exception ex) { ... stmts ... } finally { connection.close // throws an exception } which still needs a try - catch block inside finally. What is the best practice to overcome this? ...

Critique my exception handling strategy

I've been doing object-oriented programming for most of the past 7 years, using Java on and off during that time. Some things I'm certain I have an excellent grasp of, such as the most useful design patterns. In fact, the following code allowed me to crank out a little system in under a day's time, that would handle the one particular ...

What's the quickest way to remove an element from a Map by value in Java?

What's the quickest way to remove an element from a Map by value in Java? Currently I'm using: DomainObj valueToRemove = new DomainObj(); String removalKey = null; for (Map.Entry<String, DomainObj> entry : map.entrySet()) { if (valueToRemove.equals(entry.getValue())) { removalKey = entry.getKey(); break; } } if (remova...

GWT or Servlet+JSP for a web-app java project?

I've developed a java program that stores entities (using jpa+hibernate) in a mysql database. The entities are users, and other kind of objects. Now I need to write the web side of the application: I need to let user register/login and browse entries that are stored in the db. I'm new to this kind of programming and I don't know what is ...

Howto make Java JNI KeyListener with C++

I'm trying to make a program like AutoHotKey, but with a graphical interface. I'm using java.awt.Robot Now I want to make the code for checking the state from a key (In AHK: getKeyState) Of course somthing like a KeyListener without having focus. I read already something with JNI and C++, but.... I can't find some information. Can someb...

Run Executable In Jar With ProcessBuilder

I have an application I've built that uses a non-Java executable that it calls via ProcessBuilder: ProcessBuilder pb = new ProcessBuilder(invocation); pb.redirectErrorStream(true); Process proc = pb.start(); InputStream is = proc.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedRead...

Question about arbitrary validation in JSF

Hey, I have this a field: <h:inputText id="email" value="#{user.user.email}" title="Email" validator="#{user.user.validateEmail}"/> The validateEmail method checks if the email address's length is greater than 0, if not, it throws an exception. I thought this would work, but sadly the method is called only if you enter a value. Why? ...

How to create a unique label with incrementing keys for duplicates?

This is a programming technique problem in the context of Java. Problem: We have String keys that all need to be unique. The implementation of the collection is a combination of Map and ArrayList which allows one to use the collection as either a Map or ArrayList (JFreeChart's DefaultPieDataset if you are curious). If we have a single p...

PHP Java combination for multithreaded processing - good or bad ?

Hello, i need to make multiple calls to different web services using PHP and i was wondering if the php-java combination would be more appropriate in dealing with this issue. The multiple calls to the services if called sequentially will create a significant amount of delay, so i am looking for ways to overcome that. I have read arti...

How do I add `java` to the command path on Vista?

I have JDK installed in Vista. I want to run java from the command line. How do I configure the path variable? If I'm not able to set the JAVA_HOME variable, what is an alternative? ...

Using JDBCTemplate with a Hibernate SessionFactory?

We have a Spring/Hibernate app and would like to add a small amount of JDBC for reasons involving performance and development time. I can make this dao subclass HibernateDaoSupport and use the session's connection to perform my JDBC, but I'd rather use JdbcTemplate. JdbcTemplate, however is initialized using a java.sql.Datasource. How...

How to mix java swing and java fx in swing application?

i am developing a java swing application but i want to also use java fx with swing is there any resource for that told how to do that? ...