java

Vim Editor is very smart?

I am programming in C++ or Java. So I want to use Vim editor, because it is very flexible. I have heard that I can configure the Vim editor to be able to go from object to the definition from function to the definition from class name to the definition Do we have any professional Vim-er that could tell me how exactly to configure Vim...

encode xml while printing SOAPMessage

Hi, I have written a function to pretty print a javax.xml.soap.SOAPMessage to a string: public static String soapMessageToString (SOAPMessage msg) { try { Writer out = new StringWriter(); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = t...

Priority queue in Java?

Is it possible in Java to create a PriorityQueue of objects where the key that decides the priority is the member of the object? All the examples I see on net insert an integer into the PriorityQueue and retrieve them. I'm looking for an implementation that would insert an instance of an object and is retrieved based on one of its membe...

Update cached data in a hashtable

In order to minimize the number of database queries I need some sort of cache to store pairs of data. My approach now is a hashtable (with Strings as keys, Integers as value). But I want to be able to detect updates in the database and replace the values in my "cache". What I'm looking for is something that makes my stored pairs invalid ...

Spring list beans by type

Is there a way in Spring that I can auto populate a list with all of beans of a type AND any of its subtypes? I have a setter method that looks like: setMyProp(List<MyType> list) And I would like to autowire in any beans of MyType and all subclasses of MyType. Thanks, Jeff ...

Can I compress HTTP Requests using GZIP?

I am communicating to a Tomcat Server using a Java ME application on my mobile device. I was wondering if I could compress my requests/responses using Gzip to reduce the number of bytes sent over the network. ...

Are there any Java MVC frameworks that utilize request path patterns instead of defined servlet url patterns?

From what I know of MVC outside of the Java world (PHP and Ruby on Rails), all requests are first sent to the front controller (or dispatcher... or boostrap, etc.), and the front controller looks to the request path pattern in the URL in order to determine what class/method should handle the request. In Java MVC, it appears that servlets...

How to remap a keyboard key using Java Swing?

how to remap a key in keyboard using java so that i could give new meaning to a key ...

java language. it says my file doesn't exist but it does

private void traverse(String dir, int ctr) throws IOException { // get current file and name File myFile = new File(dir); System.out.println("dir path: " + myFile.getAbsolutePath()); // correct path System.out.println("exists? : " + myFile.exists()); // returns false String name = myFile.getName(); System.out.println(dir +...

JVM throws OutOfMemory during gc though there are plenty memory left...

I have my java application configured to use 5G memory. I got an OutOfMemory out of blue. I inspected the gc log and found plenty of memory left: young generation occupies 4% allocated space, tenure generation occupancy is 5% and perm generation is 43%. I am puzzled why JVM throws an OutOfMemory at the gc time. Does anyone know why this ...

JFrame does not hide when setVisible(false)

import javax.swing.*; class Frame extends JFrame{ Frame() { JFrame j = new JFrame(); j.setBounds(100, 200, 120, 120); j.setTitle("null"); j.setVisible(true); j.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } } public class test001 { public static void main (String Args[]){...

@EJB annotation - what error handling is appropriate?

The @EJB annotation can be use in "managed clients" to access an EJB. One can place this annotation in a servlet class, declaring a member variable. public class MyServlet extends HttpServlet { @EJB private MyWorkerInterface theWorker; } That @EJB annotation is expanded to JNDI lookups that (I assume) are executed when th...

how to connect and sends data betweens many computers using Java networking

Hi, I am beginner of learning Java Networking.I want to connect 3 or more computers. One for server and others(eg A and B )for clients .But I want to connect A to Server and vise versa B to Server and vise versa A to B and vise versa First I want to send message from either A or B to server and server sends stored data to send...

Java nio, checking if a channel is ready for read, write

Instead of using a selector in the usual way, where for each ready channel a message can be determined and sent, I'd like to choose whichever connection is currently ready and send a message there. Presumably this can be done by throwing all the channels into a selector for reading and marking them ready for reading if they come out, t...

Problem connecting to java ws

Hi, I've created EJB Stateless Bean and have added @WebService, @WebMethod annotations to be able to access it as web service. I am using NetBeans and GlassFish. When I tested web services with server console they worked as expected. Next I've created .net application which is supposed to be client for my web service. The problem is whe...

java internationalization in local languages

I am staying India(has more than 20 languages) I am trying to implement java-internationalization in the website. But in Locale.getAvailableLocales() the local languages are not available. is it possible to implement internationalization in my case? If possible what will happen to the fonts? How am i going to load the proper fonts in...

Dealing with special characters in a URL using Java.

I've written a Java program to generate an m3u file based on a CD ripped from k3b which pretty much preserves special character encodings in artist, album and track names. I then place these m3u files on a server and generate a GWT web application where the m3u file name is the target of an HTML anchor tag. For 99+% of cases, this all ...

How to do an Integer.parseInt() for a decimal number?

The Java code is as follows: String s = "0.01"; int i = Integer.parseInt(s); However this is throwing a NumberFormatException... What could be going wrong? ...

Fail-safe way of round-tripping JVM byte-code to text-representation and back

I'm looking for a fail-safe way to round-trip between a JVM class file and a text representation and back again. One strict requirement is that the resulting round-tripped JVM class file is exactly functionally equivalent to the original JVM class file as long as the text representation is left unchanged. Furthermore, the text represen...

Spring sessionForm in Google AppEngine

My sessions in Google Appengine works in the development environment but not when I deploy it. I have sessions-enabled set to true in my appengine-web.xml. Am I missing something here? I had to override the initBinder in my Controller for it to work in appengine because Spring tries to "access the system class loader" Maybe I should a...