java

In Java switch statements on enums, why am I getting a compilation error when I qualify my values in each case?

I have a switch statement in Java, on an Enum which let us call IMyInterface.MyEnum Each of my case statements has the form: IMyInterface.MyEnum.MyValue, (though I could drop the IMyInterface if I imported). However, the compiler (Java 6) throws an error: "The qualified case label IMyInterface.MyEnum.MyValue must be replaced with the u...

Java Build Process / YUI Compressor Issues

I am very new to Java programming so please bare with me. I am building a build process for our web development team. All it needs to do is read a global.css file, find all the stylesheets that are used for the project, concat them into one large file, then compress this file using the YUI Compressor. So far I am all the way up to the po...

Access Hotmail Unread Mail Count via Java

I want to write an application using Java6 that can check a users Hotmail inbox for the 'unread message count'! There is a Javascript API but I will not have a browser instance, and it seems that I need one to use it. (see stakoverflow question: 964392 ) I can use POP3, but since it does not support flags, I can only tell how many 'new...

Does Mediator Pattern work in this situation?

So for my current project, there are basically three main Java classes: GUI Instant Messaging Computation Essentially, there needs to be full communication, so we've decided to use the mediator approach rather than than allow the GUI to run the entire project. Basically, the mediator is going to encapsulate the communication. The pr...

jaxb marshall complex structure

Hi, I have a structure like this: Hashtable<String, ArrayList<Hashtable<Integer, Integer>>> complexTable And I want to marshall this using JAXB. I suppose I should write an Adapter for this, but I have no idea how this adapter should look like. Can anybody help me with this? ...

In GWT, what does the "[...].java' is removed due to invalid reference(s)" mean?

I have converted a GWT Eclipse based project to GWT-Maven but when I run the command mvn clean gwt:compile I get an awful lot of errors that specify: [class name].java' is removed due to invalid reference(s): My pom.xml dependencies are: dom4j-1.6.1 commons-httpclient-3.1 gwt-servlet-1.6.4 gwt-user-1.6.4 junit-4.3.1 gwtext-2.0.5 ...

How do I overwrite a log file in log4j?

I have a log file that has the following appender added to it : logger.addAppender(new FileAppender(new PatternLayout(),"log.txt")); the thing is, each time I'm running my application, additional logging information gets appended to the same log file. What can I do to overwrite the file each time ? ...

compile j2me using ant

i am created a j2me project with this article(http://www.securitypronews.com/it/applicationdevelopment/spn-19-20030611J2MEUsingAntwithJ2ME.html) and now i have problem in add resources(same as images) and librabris (same as jar as zip files) . i am copied resources in "res" folder that is points in the this article but when i extract jar...

Java optional parameters

How do I use optional parameters in Java? What specification supports optional parameters? ...

Does JDOM have any support for ID and IDREF?

<!DOCTYPE inventory [ <!ELEMENT book (title,author)> <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ATTLIST book year CDATA #IMPLIED> <!ATTLIST book myId ID #REQUIRED> <!ATTLIST book myIdRef IDREF #IMPLIED> ]> <inventory> <book year="2000" myId="1"> <title>Snow Crash</title> <author>Neal Stephenson</author> ...

Running a jar archive in a running Java application

Hi all, I am new to java programming. I want to run a runnable jar archive from within my running Java application. I need to be able to control the running classes from within my application (i.e. Stop, start them etc). Basically I need to do the eqvilient of "java -jar X.jar". I cannot use Runtime.getRuntime().exec("...") as the jar...

How to parse a currency Amount (US or EU) to float value in Java

In Europe decimals are separated with ',' and we use optional '.' to separate thousands. I allow currency values with: US-style 123,456.78 notation European-style 123.456,78 notation I use the next regular expression (from RegexBuddy library) to validate the input. I allow optional two-digits fractions and optional thousands sepa...

Handling Unicode surrogate values in Java strings

Consider the following code: byte aBytes[] = { (byte)0xff,0x01,0,0, (byte)0xd9,(byte)0x65, (byte)0x03,(byte)0x04, (byte)0x05, (byte)0x06, (byte)0x07, (byte)0x17,(byte)0x33, (byte)0x74, (byte)0x6f, 0, 1, 2, 3, 4, 5, 0 }; String sCompressedBytes = ...

How can I detect if a Java class is called by its own main() or from another class?

I have a Java class that looks like this: public class My_ABC { int a=0; boolean B=true; static // Initialize and load existing data only once at start-up { // need to know if it's called from its own main() // or by another class to conditionally set veriables } public My_ABC(int AA,boolean BB) { } publ...

Writing to Java Properties file contained as a Resource in a Jar File

Is there a way to modify the property values in a Properties file that is stored in a Jar file as a Resource? This is the scenario that I am trying to handle. I have a properties file stored as a resource in my Jar file. There are some system specific properties, for example, paths. I want to be able to change this for the system that...

Java Reading Undecoded URL from Servlet

Let's presume that I have string like '=&?/;#+%' to be a part of my URL, let's say like this: example.com/servletPath/someOtherPath/myString/something.html?a=b&c=d#asdf where myString is the above string. I've encoded critical part so URL looks like example.com/servletPath/someOtherPath/%3D%26%3F%2F%3B%23%2B%25/something.html?a=b&c=d...

NullPointerException with an override method.

Can anyone comment with their opinion on the best way to resolve the following issue? I've tried init blocks and initializing the field in the constructor, but neither get called before the overridden method tries to clear it. class TestRunner { public static void main(String[] args) { ftw ftw = new ftw(); ftw...

IOException for drive full or out of space

I am looking for a list of platform-specific (JRE-specific) of IOException messages indicating disk is full or out of space. So far I have: Windows: "There is not enough space on the disk" Solaris/Linux?: "Not enough space" GCJ: "No space left on device". I wish Java would make an IOException subclass for this... ...

Can Netbeans handle both 32-bit and 64-bit version of Java ?

I'm running 64-bit version of Vista on my notebook with 4G of RAM, the Ram is maxed out at 1.5G on the 32-bit version of Java. But if I move completely to 64-bit version of Java, the JDIC part won't work, so my question is : if I install both 32 and 64 bit versions of Java, can Netbeans easily switch between the two ? So if I run out of ...

How can I get the text from a component in a JList?

I have a JList and I am wanting to get the text of an entry of that list at a specific index. Could someone inform me how to do this or should I restructure my code to getValues instead of getIndices? ...