java

JWindow alway on top not getting focus events.

I have a jwindow(set to be always on top) that you can click to get a pop menu. If the user right clicks the window it shows the pop menu but then if the user clicks any other window(such as firefox) pop menu does not disappear. I tried to fix it by adding FocusListener on the jwindow, i implemented FocusListener and override pub...

Architectures for a Java web application

What are the different architectures for developing professional and organized Java Web Applications? I have heard about MVC architecture, what architecture else does, for example, Stackoverflow, google, orkut, etc.. use for a scalable, robust and easily-maintainable-from-the-developers-point-of-view, exist! ...

Java Class Path

Hi, I am learning java at the moment and I am a bit confused on where or how to set a class path? I am using Jcreator Pro. Do I set it in the source file or in the IDE or in Windows somewhere? Any help would be greatly appreciated. ...

How to use two numbers as a Map key

I have two numbers and I want to use them together as a key in a Map. Currently, I'm concatenating their string representations. For example, suppose the key numbers are 4 and 12. I use: String key = 4 + "," + 12; The map is declared as Map<String, Object>. I think this is so bad! I like to use something other than a String as the ke...

java.util.logger constructor description bug or javadoc error ?

When I got a new logger it always had the level set to INFO but the documentation told otherwise (null), Hence I opened the code. The documentation and the code doesnt match. I am putting it on stackoverflow for others dont have to struggle /** * Protected method to construct a logger for a named subsystem. * <p> * The logger wil...

Can JAXB generate a generic class?

Can I get JAXB 2.0 XJC compiler to generate a generic class for me? Something as simple as:- public class Shape<T> { T myShape; // getter / setter } I see references for this in the spec but am not sure I'm reading it right. I always get Object references. ...

enabling UTF-8 encoding for clojure source files.

Hi all, I'm working on a project which involves maven, java and clojure. The problem I'm facing is this, I have some UTF-8 chars in my clojure source files because of which my source code is not interpreted correctly by the java compiler, I kinda got it working by setting the environment variable JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF...

GWT 1.7 - Configuring a DataSource in Jetty (Hosted Mode)

Hello, I'm new to GWT (1.7) and tried to establish a connection to my MySQL database from the servlet. Because I got some errors, I googled them and found out, that I have to configure a DataSource in Jetty to get it working in Hosted Mode. I followed this tutorial: Tutorial I created my own JettyLauncher class as described and added th...

Append node to an existing xml-Java

I have seen the same question being answered for vb and c#, but i need a Java best solution for appending nodes to an xml. Will xpath help? I have <A> <B> <c>1<c/> <d>2<d/> <e>3<e/> </B> <B> <c>1<c/> <d>2<d/> <e>3<e/> </B> </A> Need to append another <B> <c>11<c/> <d>21<d/> <e>31<e/> </B> ...

Build numbers: major.minor.revision

How would you write a build.xml file, using neither custom code nor external dependencies (such as a shell script), that: Generates a build number of the form major.minor.revision (e.g., 01.02.34). Auto-increments the revision on each compile of the source code. Auto-increments the minor version on each execution of a dist(ribution) ta...

Getting the correct Hibernate template in a generic Spring CRUD DAO

Hi, I'm still quite new to Spring, and I've found it to irritating making all these CRUD DAOs, so I've made a "public class GenericCRUDDAO extends HibernateDaoSupport implements CRUDDAO". In my service objects I then simply say something like private GenericCRUDDAO<User, Integer> userDAO = new GenericCRUDDAO<User, Integer>(); and no m...

Get server date problem

Hi, I have problem with getting server date (linux server). When I use linux 'date' command I get properly date value (real date). If I modify some file on server, modify date is also properly (real date). But if i use java code System.out.println(new Date()) on server I get date with 1 hour difference i.e. linux 'date' command result = ...

Any WorkAround For Java ResultSet Limitaion

I am doing a database migration work. I have to copy a database in MSSQL to MySql database. It was possible to come up with a small java utility to copy table stucture from MSSQL to MySql Database. Now i have to copy all data from MSSQL to MySql. I tried using resultset in java to obtain all data from a table but then it could only fetch...

why it is better to convert hashset to treeset then working directly with treeset

In many places in the web including sun website, the following sentence appear: It generally faster to preform actions on hashSet and then convert the hashset to treeset. well, i'm a little bit confused, thats correct that add element in hashset is o(1) and adding object in treeset (black & red tree) is o(logn) but when i conve...

Stateless EJBs: Finding the balance between performance and security

I have a JSF web client and a Java client that both use the same stateless EJB layer for their application logic. I'm unsure of how to balance the need for performance (limiting the amount of data that is transported between the presentation and application layers) with security (in the sense of ensuring all decisions are made based on u...

How is the Eclipse JDK setting affecting the system's JDK setting

I was trying to compile a Grails application referencing third party JARs on Mac OSX. Although my system's JRE and JDK is set to Java 1.6 I always got a Compilation error: java.lang.UnsupportedClassVersionError: Bad version number in .class file when accessing classes in the JAR. Also when testing an existing Grails app the default stats...

Find all matches in a Java Collection

Ok. Here is a problem. This is my collection : {2,3,4,2,3,5}. Let's assume that it is a List for now. I would like to search this collection for all matches of '2'. I would like indexes of the same. I know that there are indexOf() and lastIndexOf() methods in List and Arrays.binarySearch(). However, all of them return one element indicat...

Command Line Pipe Input in Java

Here is a simple piece of code: import java.io.*; public class Read { public static void main(String[] args) { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); while(true) { String x = null; try{ x = f.readLine(); } catch (IOException e) {e.printStackTrace();} System.out.println(x); ...

Shutting down an ExecutorService

In Tomcat, I wrote a ServletContextListener which will start an ExecutorService during startup and terminate it when it is unloaded. I am following the example in the javadoc for ExecutorService public void contextDestroyed( ServletContextEvent sce ) { executor.shutdown(); try { executor.awaitTermination( 50, TimeUn...

Accessing Local file from a browser?

Hi I want to access a local file of my system from the browser? Is there anyway through which it can be achieved as there are lot of security checks invloved? or any other work arround using ActiveX or Java Applet???? Please help me out.. ...