java

Does anyone have a beginners guide to installing and using glassfish?

I am after a all round installation and introduction to Glassfish. (ie Your boss has told you need to develop your web applications for glassfish instead of tomcat) ...

How does Java Graphics.drawImage() work and what is the role of ImageObserver

How should Java's drawImage() be used? I do not find the JDK documentation very forthcoming. For example all drawImage signatures require an ImageObserver but the documentation for this is not very helpful for new users. ...

What is the glassfish alternative to context.xml

I am used to configuring web application in context.xml, including jdbc resorces, and application configuration parameters. Under glassfish, what is considered the standard place to store application configuration information? We used to store it in the context.xml file as follows: <Resource url="jdbc:mysql://localhost:3306/db?useUnic...

Cached data Synchronization to Database

What are the best ways to keep data synchronized between in memory cache and the database when used in a web application? Specifically, I store large amounts of database data in an in-memory cache using EHcache on my web application. For many interactions, I would like to simply modify the value in cache, and only synchronize it with the...

can I tell Hibernate a class is immutable so it will share the objects to save cost of construction?

I have some classes that represent immutable objects (Quantity, Price, Probability). Is there some way to tell Hibernate that the objects will never change so it can re-use objects rather than creating a new object for every instance of 0 or 1 or Price= $1? I ended up creating these classes because I discovered that doubles don't do ...

How to REINSTALL Java 6 on Mac OS X Snow Leopard

OK, I am idiot and messed with my Java install trying to get Resin to work. Now, things are broken. I figured I could just reinstall the developer tools that came with my new Mac (brand new 13" MacBook Pro) and that would take care of it. Alas, I was wrong. Snow Leopard comes with Java 6 JRE and JDK but as far as I can tell YOU CANNOT ...

Fastest way to find duplicates in a string without using any additional memory in java?

What is the fastest way to remove duplicate character in a string without using an extra memory in Java? ...

Qt Creator plugin for Java

Hi everybody: Do you know if there is some available Qt Creator plugin to add Java support to this nice IDE? Thanks in advance, Ernesto ...

Convert Java resultset to String array

Hey everyone, I am writing a program that will query an MS access database, return the query as a result set, and then I want to ultimately convert that result set into a String array, so that I can pass it into the constructor of a Swing JComboBox - so the ComboBox will list the items returned by the query. I have been able to store t...

why does a return statement inside a try catch work with 'throws'

does not work (Compilation error: missing return statement) public SqlMapClientTemplate getSqlTempl() throws UivException, SQLException{ try { SqlMapClient scl = (SqlMapClient) ApplicationInitializer.getApplicationContext().getBean("MySqlMapClient"); DataSource dsc = (DataSource) ServiceLocator.getInstance().getDataS...

how to enable SQL trace for a closed source app running on jboss and using ojdbc14.jar

Hello Hackers! I have a java app (deployed on Jboss/ WebLogic) that I have to use, it uses ojdbc14.jar to talk to oracle, it's is a neat app but the documentation sucks, a lot of magic happens behind the scenes. I need to trace all SQL calls. I have complete control on DB, App servers, DBA rights, admin rights everything. How do I do ...

How to "cat" a file in JGit?

A while back I was looking for an embeddable distributed version control system in Java, and I think I have found it in JGit, which is a pure Java implementation of git. However, there is not much in the way of sample code or tutorials. How can I use JGit to retrieve the HEAD version of a certain file (just like "svn cat" or "hg cat" wh...

generics calling constructor

I am trying to do something I would not normally do, it is a bit odd, but I'd like to make it work. Essentially I have a factory that has to create objects by calling the constructor with different types of data (A and B take different types in the code below). I seem to have gotten my self stuck going down the generics route (I do nee...

How to copy the directory using ant

Hi, I have used copydir to copy the directory. Actually my directory contains some sub directories. Out of which some contains file and other some contains again contain sub directories. Now I want to copy everything. So how to copy all the contains of the directory using ant. Thanks Sunil Kumar Sahoo ...

How to read number and display it to unix console with pipe symbols.

Hi. Id like to make simple digital clock just from symbols. My idea was to make this template: { System.out.println(" _"); System.out.println("|" + "_"+ "|"); System.out.println("|" + "_" + "|"); } _ |_| |_| BUILD SUCCESSFUL (total time: 0 seconds) _ _ _| | _| |_ | _| ....etc and t...

how to convert programatically powerpoint to xml and back

I need to convert powerpoint file to a text based file such as xml o html programatically and do some proccesses in it and again convert the textbased file top powerpoint. I prefer to do it with java. ...

Java conversion to php?

Is it possible to convert this java code snippet to php? public void testBalanceReturnsToZeroOnVending() { sodaVendor.insertCoin(50); sodaVendor.insertCoin(20); sodaVendor.insertCoin(5); // The price is right! assertEquals("We have entered correct money", ...

Simple Java Map puzzle

What is the best implementation for this general-purpose library method? public static <K, V> boolean containsEntry( Map<K, V> map, K key, V value) {} Criteria for judging this puzzle, as with most coding puzzles, are in this order: Completeness Correctness Performance Beauty Receipt of PayPal contribution EDIT: Well, since i...

Find the gender from a name

Hi guys, I recently confronted with a weird yet interesting question. The questions is as follows: Need to write a program which can give the gender as output based on the name. Example: INPUT --> John Michael Britney OUTPUT--> male male female So this ...

Text processing / comparison engine

Hi, I'm looking to compare two documents to determine what percentage of their text matches based on keywords. To do this I could easily chop them into a set word of sanitised words and compare, but I would like something a bit smarter, something that can match words based on their root, ie. even if their tense or plurality is differen...