java

Generics and the question mark

Hi! I'd like to use a generic list, but the initialization method only returns a List. The following code works well: List tmpColumnList = aMethodToInitializeTheColumnList(); tmpColumnList.add("ANICELITTLECOLUMN"); Java accuses that I'm using a raw type and I should paramerize the list. So I added the question mark parameterize this ...

Matching part of regex

I must to match the stars(*), that satisfied such conditions: \*\S.*\S\* -> (for example *y text1 text2 u*) The problem is, that i want to match only this stars, if the condition is true, how can it be done(desirable in java:))(i have write so: Pattern params = Pattern.compile("\\*\\S.*\\S\\*"); but this matches stars and text bet...

What is called defer-node-expansion in XML?

Hello All, What this feature "http://apache.org/xml/features/dom/defer-node-expansion" does? i have read about this feature. But was really unable to understand what will happen if this is set to false. Can anyone come up elaborately on this as i don't find any other link that explain to the ability i understand. ...

Wicket: how to synchronize requests within session

Scenario: Apache Wicket based web application running on Tomcat server. User opens URL in browser, session is created and simple main page is shown in browser, user clicks on button and AJAX call is invoked. Application gets request and doing some stuff preparing response. In same time user or JavaScript in browser invokes another AJAX...

Is there any way to make a window fixed?

Is there any way to make a window fixed so that the user can't change the window size in java? ...

Check for two adjacent bits in 2D array (Java)

I am writing a tic-tac-toe game in Java. I have a 2D array representing a 3-by-3 grid, and need a method to check if there are 2 bits set in such a way that a row of 3 can be formed by adding a third bit. The only way I could think of doing this is to iterate along the rows, checking for a blank space, then checking the bits around it,...

ThreadLocals hard to use

I'm using ThreadLocal variables (through Clojure's vars, but the following is the same for plain ThreadLocals in Java) and very often run into the issue that I can't be sure that a certain code path will be taken on the same thread or on another thread. For code under my control this is obviously not too big a problem, but for polymorphi...

Solving "loader constraints violated when linking [...] class" error in Java

I am new to Java and experiencing problems understanding exceptions thrown by the framework. Right now, I am trying to implement a regular expression validator into an application consisting of Java 5 EE with myFaces 1.2 and Tobago running in an apache tomcat 5.5. I followed a couple of tutorials (including the Java 5 EE tut from SUN) ...

My program needs to access information (key/value) from my hosted server. What web architecture would be best for this?

My program needs to download object definitions (basically xml files, maybe binary files) on demand via the net. The program will request objects from my server during runtime. The only thing the program has to send the server is a string that identifies the object it needs (e.g. RedCubeIn3DSpace23). So a basic Key, Value system. My app ...

export a report and save in a location using jasper

I need to export a report and save it to a location specified, i have exported the report but i want to know how to save it in a file location, it is a doc or rtf format ...

java webservices

Hi We have a current jee project and a new requirement to introduce a webservice into the project. We develop on Rad 7 and deploy to Websphere 6.1, but this could change soon to deploy to tomcat. What i was wondering is, what approach should we take for developing these webservices? Should we develop RESTful webservices and use JAXB? S...

Relationship with Enumerated Type in Java

I'm trying to create a many-to-many relationship between two types of which one is an Enumerated type. Lets say the first model is User and the second model is Role. A user can have many roles and a role can belong to many users. I'd like to be able to write simple code like: if (user.getRoles().contains(Role.ADMIN)) { //do something...

How to find the IP Address of Client connected to Server?

My client pc is connected to as server pc via sockets over Ethernet, How do I find the IP of this client from the server side code. The server is dishing out one socket per client in a new Thread. When I do a csocket.getLocalAddress().toString() on the client socket I still get the Server IP address. (csocket is the socket that the Serve...

How to add default item like Add New Item at top of JComboBox

How can I add a default entry at the top of a JComboBox such as Add New Item in order to allow a user to click this entry and get a dialog allowing them to create a new entry? Should I try to use a custom renderer or what is the best approach? I appreciate anyone's assistance with this. ...

Java Error using Vectors: unchecked call to add(E)

Offending bit of code Vector moves = new Vector(); moves.add(new Integer(x)); Error: ConnectFour.java:82: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector moves.add(new Integer(x)); Not really sure how much info is needed for an error like this.... ...

Taking the next step with java development?

I want to take the next step in java web development, I am hoping to get insight & feedback on: what my next steps should be and how best to take them. While learning the basics of java web development, I put together a simple web app that performs simple accounting and financial calculations. The web app is on a single jvm, uses Tomca...

make document available for download through java/servlet

hello everyone I need to know if there is a way in java/servlet to make documents(doc,pdf) stored in database available for download to users in requested way(please see below), for example there is a web page and the link for document in it right now it is done this way: if the user clicks that link than a new blank window opens and ...

How can I read/write bits from/to a file in Java?

I need to read file stream as bits and then I should be able to write bits to file again. Are there any classes for this purpose? ...

Using outer joins in HQL queries

I'm trying to build a query using HQL and OUTER JOINs and just can't get it work. Consider the following mapping <class name="Parent"> <id name="id" type="integer"> <generator class="native" /> </id> </class> <class name="Child"> <id name="id" type="integer"> <generator class="native" /> </id> <many-to...

java.lang.NoSuchMethodException: com.mchange.v2.c3p0.PoolBackedDataSource.setUserOverridesAsString(java.lang.String)

Hi all. I'm using C3P0 0.9.1.2 to configure data sources for my connection pool. When context is loading an error is raised. Here is the trace: java.lang.NoSuchMethodException: com.mchange.v2.c3p0.PoolBackedDataSource.setUserOverridesAsString(java.lang.String) at java.lang.Class.getMethod(Class.java:1605) at com.mchange.v2.c3p0...