java

Explanation about Annotations

Hi, Can anyone please explain what the following two paragraphs mean, in simple english? (Taken from http://www.ibm.com/developerworks/java/library/j-cwt08025.html) "Annotations are more flexible in terms of how you use them, with options for whether the annotation information is to be included in class files output by the c...

MVC pattern in JAVA

What are the advantages and disadvantages in MVC patterns when it's using in Java? ...

Storing multiple values in cookies in Java

I see many solutions for storing multiple values in one cookie in .Net and php but I have not found any good solution for Java. I dont wanna encode/decode the pair-values myself which can be risky. ...

commons-logging and log4j properties file

I am trying to use log4j via commons-logging and having problems if the log4j properties file is not called log4.properties. I get following error: log4j:WARN No appenders could be found for logger (LogMePlease). log4j:WARN Please initialize the log4j system properly. My code is very simple: import org.apache.commons.logging.Log; impor...

Can you recommend a lightweight java portlet software?

Hello, I am a long time java web developer but I am new to portlets technology. Currently I am in the stage of finding my options. I have tried Liferay and although it is very cool, it is a bit heavy for my needs. Can you recommend a more lightweight portlet container? ...

How can I check if an InputStream is empty without reading from it?

I want to know if an InputStreamn is empty, but without using the methods read(). Is there a way to know if it's empty without reading from it? ...

Serializing immutable java classes to actionscript with LCDS

Hi, I've got a complex object which is being managed by the LCDS DataServices data management and being created/updated etc using custom assemblers. The vast majority of the object hierarchy is being serialized/deserialized correctly but I've hit a stumbling block when it comes to serializing immutable java classes. In a java only worl...

Java : static fields behaviour in different executions

I have this class : package scripts; public class TestStatic { public static void main(String[] args) { new IncrA().incrStatic(); } } class Static { public static int CPT = 0; } class IncrA{ public void incrStatic(){ for (int i:Range.ints(0,100)){ System.out.println("Now with "+this.toString()+" : Static.CPT="+Static.C...

Java email and yahoo

I use my email server to send email. I can send my emails to gmail successfully(I can find my emails in my gmail spam folder) but when I wand to send yahoo mail my emails is not recieved by yahoomail I check spam folder. but can not find it. ...

Browser download complete event

We've been looking for a while for an answer to this, but haven't found a solution. We have a web server, which allows the user to download files (pdfs), which are dynamically-generated and served from servlets. We'd like to know when a download has completed (and how: was it successful, did it fail, did the user cancel?). Is there a...

String variable to a DefaultMutableTreeNode object?

Is it possible to convert a String variable to a DefaultMutableTreeNode object? Please explain. Context: String s = new String(outputTagName); Object s2 = (Object) s; DefaultMutableTreeNode selectedNode2 =(DefaultMutableTreeNode) s2; DefaultMutableTreeNode parent2 =(DefaultMutableTreeNode) parent; model.insertNodeInto(selectedNode2, ...

Recovering HyperSQL Database

We are using JBoss 4.0.3 SP1 using Hypersonic as its internal storage engine (timers, queues, etc.) The database is no longer accessible (most likely data corruption) giving error; Caused by: org.hsqldb.HsqlException: old version database must be shutdown. Is there a way or command to shutdown the database to recover the data (~150MB) ...

The best CLI parser for Java

What CLI parser for Java is easy to use and more scalable than others? ...

any java applet programe returning client system resources information

is there any java applet programe which gives client system information. as which hardware he is using(in my case fingerprint reader) ...

How can I in a jsp page get maven project version number?

Hello guys, I am working on a java web application, managed by maven2. From time to time, we did some changes, and want to do new releases, of course with new version number. In the homepage (jsp), there is text like <b>version:</b> 2.3.3... Is it possible, every time I do a new release, I only change the <version/> in pom.xml, and ...

How to calculate the font's width?

I am using java to draw some text, but it is hard for me to calculate the string's width. for example: zheng中国... How long will this string occupy? ...

Profile CPU usage in Java on a Mac

I'm looking for a way to measure the cpu usage for different methods in my java code. I understand that this can be achieved using JNI and C, but I wouldn't know where to start... The purpose of this is to compare different algorithms, and provide qualitative results. ...

File.createNewFile() thowing IOException No such file or directory

I have a method that writes to a log file. If the file exists it should append to it, if not then I want it to create a new file. if (!file.exists() && !file.createNewFile()) { System.err.println("Error with output file: " + outFile + "\nCannot create new file."); continue; } I have that to check that a file can be create...

simplified boundary checking for Java List

Is there an easy way/library to check and adjust parameters to stay inside the lists boundaries? Here a long sample: if (fromIndex < 0) { fromIndex = 0; } if (fromIndex > list.size() - 1) { fromIndex = list.size() - 1; } if (toIndex < 0) { toIndex = 0; } if (toIndex > list.size() - 1) { toIndex = list.size() - 1; } list.subLi...

Storage-In-File Database for C#/.NET 3.5 ?

Is there something like HSQLDB (for Java) which can be run in a storage-in-file mode for C#/.NET 3.5? ...