java

Java Calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY), will it roll backwards, forwards or unknown?

Suppose the following code is executed on the 22nd of August 2009 (a Saturday) Calendar c = Calendar.getInstance(); c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); c.get(Calendar.DAY_OF_MONTH) will return 23. I'm interested in the conditions is would return 14 (last Sunday, rather than the next Sunday). Are there any rules assoc...

Sets of characters

Am implementing a lexical scanner. How can i implement sets of characters? most of the character sets will be in range form i.e A-Z, h-L e.t.c. And i have to check if a character, ch is a member of a character set. Which efficient data structure can i use in Java other than arrays and Bit Set? ...

Writing desktop app that uses database. Suggestions for how to manage user access to tables?

I'm writing a depsktop application (in Java) that interacts with a database which stores mostly requirements documents,but I have a bit of a dilemma. Specifically, a problem with managing user access. To illustrate, I store all details on the folder structures in a single table. However, I would like to institute a user-group mechanism...

How does one access a method from an external jar at runtime?

This is a continuation of the question posted in: http://stackoverflow.com/questions/194698/how-to-load-a-jar-file-at-runtime I am uncertain as to how to continue to the method invocation level. From my understanding, from the clazz object, I would used getMethod or getDeclaredMethod to get a Method object from which I would call invok...

Java OS X Dock Menu

Is it possible to add items to the applications dock menu? EDIT: I think i miss phrased the question, i am not looking for a way to add an icon to the dock. what i am looking for is, when you right click on the itunes icon you get itunes control on the menu (play pause etc) i was wondering how can i add custom items to that menu. ...

A good, recent article on the comparison between Java EE and .NET?

I've started looking into a few larger server-app frameworks that would be able to support desktop client interfaces as well as web interfaces, and have really zero'd down on the two obvious ones: J2EE and .NET. From a language standpoint, feature standpoint, portability standpoint, etc...I am pretty comfortable with my understanding of ...

Using ThreadLocal with existing classes which contain static members

I'm trying to use ThreadLocal to provide thread safety to pre-existing non-thread-safe classes, but experiencing problems. It appears that there is no isolation being performed - that the threads still share the static, instead of it being local to each thread. I believe my usage is almost exactly parallel with the example localization...

Unicode in Jar resources

I have a Unicode (UTF-8 without BOM) text file within a jar, that's loaded as a resource. URL resource = MyClass.class.getResource("datafile.csv"); InputStream stream = resource.openStream(); BufferedReader reader = new BufferedReader( new InputStreamReader(stream, Charset.forName("UTF-8"))); This works fine on Windows, but on Lin...

Android: Removing items from a ListView/ArrayAdapter Activity

I have a list (of messages) and I want to give the user the ability to remove these items from the list. I have extended an ArrayAdapter and give it an ArrayList of my messages and would like to simply remove an item from that list and then refresh the listview instead of reloading the entire list of sent messages. The problem is, if the...

Why is JFormattedTextField evil?

Hi, In this question Is there any way to accept only numeric values in a JTextField? one of the answers suggested that JFormattedTextField had issues. I've not yet used it, but could somebody please expand (or disagree) on the issues with this class? Thanks... ...

Free Java Swing calendar component for date picking

I need to add ability to pick a date in my Swing application. Picking should be similar to JComboBox, but instead of drop down list I would like to obtain one month with dates and ability to scroll between months. There is no such component in JDK. A list with a lot of third party components is available at http://www.java2s.com/Produc...

Library implementation pitfalls

What practices should developers avoid when implementing libraries? For example, libraries should not use the following (or default usage should be disabled): System.err System.out exception.printStackTrace System.exit The developer of an application needs full control over the text that is presented to the user (language being one r...

java.util.Stack appropriate data structure?

Hmm. I'm noticing Stack is a subclass of Vector, and I thought Vector and Hashtable were considered "old" datastructures because of their builtin synchronization even if you don't need it. (vs. List, Map, etc. which don't provide it for you) That and it's a class, not an interface. Is there a more modern, recommended alternative? ...

Execute another jar in a java program

I had written several simple java applications named as A.jar, B.jar. Now i want to write a GUI java program so that user can press button A to execute A.jar and button B to execute B.jar .Also i want to output the runtime process detail in my GUI program. Any suggestion? ...

interface for only certain classes?

Can you create an interface which can only be applied to certain classes and subclasses? If my interface is only added to different subclasses of JComponent, and I need to refer to both the methods of JComponent and my interface... how should I do this? Off the top of my head I can accomplish this by adding methods from JComponent to ...

Good framework for Ruby web development.

Basically I am java developer and exploring ruby and ruby related framework right now. I am mostly working on web based projects. I had heard about RoR and Merb for web development in ruby. I am looking for good tutorial/books for Merb. ...

Preference API storage

Can you please tell me, if i use preference API and store user or system preferences where they will be stored in windows/unix ...

Java regex help

I'm trying to write a regular expression for Java's String.matches(regex) method to match a file extension. I tried .*.ext but this doesn't match files ending in .ext just ext I then tried .*\.ext and this worked in a regular expression tester but in Eclipse I am getting an invalid escape sequence error. Can anyone help me with this? Tha...

Abstract class in Java

What is an "abstract class" in Java? ...

How to add custom SOAP-Header element to the generated WSDL in Spring-WS

Hi, we are migrating from WebLogic web-services to Spring-WS (1.5.X). There is currently one issue we are facing: We need to pass a context object (on WLS it is passed as SOAP-Header element) to other services that are still running on WLS from the Spring-WS powered service. The header element is still formulated on client side and the...