java

How can I simulate a socket disconnection (on windows) between a client and a server?

I've implemented a kind of 'heartbeat solution' and I'd like to see what happen when the network 'goes down', in real conditions, specially if it happens when there is no traffic on the socket. Problems: - I've got only one computer; - I'm on windows/java; I guess that simply unplugging the network cable/deactivating the network card ...

Monitoring system resource use for Java

Hello, I am trying to prepare some statistics on the CPU and Memory usage (over time) of a Java application running on a Windows XP machine. Is there a (free) tool that would let me obtain these statistics? Most of the tools I looked at either profile the existing code for CPU and Heap usage - but do not provide a view the process its...

Jpanel Printing Please Someone Help

I am using PersonaC30 card printer to print my Jpanel data on card. My print method is working fine with paper printer but when i print with card printer its not printing my data. Although its printing well externally but its not working with my application please someone help me out if any of you have work with card printing i am trying...

Java WebStart: <property ...> ignored when using <extension>?

I have a problem modernizing a Java WebStart application under Java 6 u 13 (the latest at this moment) We desire to use the new mechanism to have several master configuration files each with their own configuration , which then "include" another jnlp file which is autogenerated to ensure that the jar list is accurate. After quite a...

How to read to inputstream in tcp socket communication for multiple formats in java

Hi, In TCP based communication, I need to, listen/read to, multiple formats on DataInputStream. Such as write and writeUTF. I need to identify the mode used by other end to switch to that mode such as when writeUTF(String) is used I need to use readUTF(), and if the write(byte[]) is used then I should be able to switch to read() ...

Why is my NullPointerException not being caught in my catch block?

I have a thread in which I catch all errors in a big, all-encompassing catch block. I do this so that I can report any error, not just expected ones, in my application. My Runnable looks like this: public final void run() { try { System.out.println("Do things"); /* [1] */ doUnsafeThings(); } catch (Throw...

Why can derived classes only sometimes have specialized types in overridden methods?

Let's say I have this base class: abstract public class Base { abstract public Map save(); abstract public void load(Map data); } to my surprise I could do this in a derived class: public class Derived extends Base { @Override public Map<String, String> save() { //Works ... } ... } but I couldn't ...

Hibernate using JPA (annotated Entities) and liquibase

liquibase is a perfect alternative to hibernate's hbm2ddl_auto property if you are using xml-mapping. But Im using JPA annotation (hibernate annotations). Is it possible to use liquibase then? ...

Question about Java regex

I get a string from a array list: array.get(0).toString() gives TITLE = "blabla" I want the string blabla, so I try this : Pattern p = Pattern.compile("(\".*\")"); Matcher m = p.matcher(array.get(0).toString()); System.out.println("Title : " + m.group(0)); It doesn't work: java.lang.IllegalStateException: No match found I also t...

Remove border from JComboBox

Do you know any way to remove the border from a JComboBox in Java? I try the following code public class ComboFrame extends JFrame { public ComboFrame() { JPanel container = new JPanel(); JComboBox cmb = new JComboBox(new String[] { "one", "two" }); cmb.setBorder(BorderFactory.createEmptyBorder()); container.add...

Criteria to Evaluate Business Rules Engines

We are shopping for Business Rules Engines. We want to make our core application customizable to different customers with slightly different requirements. The people who would actually do the customizations are analysts. I.e. non-programmers who are technically skilled (usually have a degree in sciences). What are the criteria to evalua...

Display 100000 records on browser / multiple pages.

I would like to display 100000 records on browser / multiple pages with minimal impact on memory. ie Per page 100 records. I would like to move page back and forth. My doubts are 1. Can I maintain all the record inside the memory ? Is this good Idea ? 2) Can I make database connection/query for ever page ? If so how do write a query? ...

Using CheckStyle in NetBeans and configuring the CheckStyle rules

I am using NetBeans 6.5. For CheckStyle, I have downloaded and installed the nbcheckstyle.nbm plugin. I am able to use CheckStyle with this plugin. I want to configure the rules to be checked. I am not able to do it as it is an .nbm file. Any suggestion on how to configures the rules? Thanks ...

Pagination through Struts2 using DisplayTag Library Framework

I want to apply pagination for some class of my application, in which i am using spring, struts2 & hibernate. Here i am calling action class from welcome.jsp file. It has following code : <s:form action="marketing/allCountry.action"> <s:submit value="Click"></s:submit> </s:form> Now my allCountry.action cla...

How to add namespace to an xml file using java program

I want to add namespace to an xml file using java program. So how can I add namespace to an xml file using java Thanks Bapi ...

Is Quercus a viable replacement for PHP in Java environments?

For anyone stumbling upon this question who doesn't know what Quercus is - it is an implementation of PHP done in Java. For a project that I am currently working on we serve php pages via cgi over servlets (I know it is clunky, but it is a requirement to support legacy code). I was excited to discover the Quercus project because it look...

How to use markSupported feature of inputstream java

I intend to use the markSupported feature for checking first byte to check the format then reset it, please tell me which stream should be used for tcp based communication in java. For most of the streams like datainputstream does not provide this feature. Please can give me some pointers to use mark and reset. ...

Java: File.toURL() deprecated?

Why is the function java.io.File.toURL() deprecated? I need to pass an URL to Toolkit.createImage() which accepts a URL object. Javadoc recommends me to use File.toURI().toURL(). However: C:\Documents and settings\Administrator\... becomes: C:\Documents%20and%20settings\Administrator\... which obviously is an invalid file location. I...

How do I repopulate a form using Java?

I have a form that is submitting to a servlet and processed with the doPost() method. Once the form is submitted, the user is taken to another page with a "Back" button (not the browser's back button). If the Back button is clicked, the form should repopulate with the original input. How can I accomplish this? ...

Getting the real (virtual) host name under an application server

I have an application running under Jetty, and I want the application to return self referencing absolute URLs (when generating an RSS feed, so a client must be able to work without a "current URL" context). The problem is that I don't know ahead of time under which host name the application will be deployed, and it is quite likely tha...