I’m attempting to compile Java 1.4 code that was created by IBM’s WSDL2Java on Java5 without recreating the stubs and saw this error in Eclipse. I’m under the assumption that the stubs generated should just compile as long as the runtime jars are available (they are). Access restriction: The…
How to make a new List in Java
We create a Set as: How do we create a List in Java? Answer or with generics (Java 7 or later) or with generics (Old java versions)
Command line progress bar in Java
I have a Java program running in command line mode. I would like to display a progress bar, showing the percentage of job done. The same kind of progress bar you would see using wget under unix. Is this possible? Answer I have implemented this sort of thing before. Its not so much about java, but what charact…
How to read an external properties file in Maven
Does anyone know how to read a x.properties file in Maven. I know there are ways to use resource filtering to read a properties file and set values from that, but I want a way in my pom.xml like: There was some discussion about this: Maven External Properties Answer Try the Properties Maven Plugin
java.util.Date to XMLGregorianCalendar
Isn’t there a convenient way of getting from a java.util.Date to a XMLGregorianCalendar? Answer I should like to take a step back and a modern look at this 10 years old question. The classes mentioned, Date and XMLGregorianCalendar, are old now. I challenge the use of them and offer alternatives. Date w…
Should Exceptions be placed in a separate package?
I am taking on a project where all the Exceptions have been placed in a separate package com.myco.myproj.exceptions. Is this good practice? Answer I would expect the exceptions for a package to exist within that package. e.g. would contain pricing models and related exceptions. Anything else seems a bit count…
What is the best way to scale images in Java?
I have a web application written in Java (Spring, Hibernate/JPA, Struts2) where users can upload images and store them in the file system. I would like to scale those images so that they are of a consistent size for display on the site. What libraries or built in functions will offer the best results? I will …
What is the Java ?: operator called and what does it do?
I have been working with Java a couple of years, but up until recently I haven’t run across this construct: This is probably a very simple question, but can someone explain it? How do I read it? I am pretty sure I know how it works. if isHere is true, getHereCount() is called, if isHere is false getAway…
Delete directories recursively in Java
Is there a way to delete entire directories recursively in Java? In the normal case it is possible to delete an empty directory. However when it comes to deleting entire directories with contents, it is not that simple anymore. How do you delete entire directories with contents in Java? Answer You should chec…
Why doesn’t java.util.Set have get(int index)?
I’m sure there’s a good reason, but could someone please explain why the java.util.Set interface lacks get(int Index), or any similar get() method? It seems that sets are great for putting things into, but I can’t find an elegant way of retrieving a single item from it. If I know I want the …