java

Creating (boxed) primitive instance when the class is known

I need a method that returns an instance of the supplied class type. Let's assume that the supplied types are limited to such that an "empty" instance of them can be created. For instance, supplying String.class would return an empty String, supplying an Integer.class would return an Integer whose initial value is zero, and so on. But ho...

Regex starting with a zero length line and continuing across lines in Java

Hi, I want to match the following: a zero length line, with the match continuing across lines of non-zero length until a particular string is matched in a line. E.g: the match starts with a zero length line and continues until STOP is reached: Some random text I don't care about The match starts at the beginning of this line The match...

JRockit Mission Control - MemLeak not showing any of my objects

I'm running a Weblogic application server, version 10.3. In it i run a couple of enterprise applications. I suspect a memory leak so i booted up mission control and memleak. The problem is Memleak Tren tab doesn't show any of my own objects only bea, java and sun objects are listed. I sincerely doubt mine occupy less than 0,1% of the he...

Tomcat: Change the Virtual hosts programmatically?

Hello, Tomcat offers a build in "Virtual Hosting" Support: An Engine/Web-Application can be configured to be responsible for a list of Domains. These Domains have to be put into the server.xml/context.xml files with a special xml directive. => Is there any possibility to change the Tomcat Configuration (in general) and especially the "...

How to tell why a file deletion fails in Java?

File file = new File(path); if (!file.delete()) { throw new IOException( "Failed to delete the file because: " + getReasonForFileDeletionFailureInPlainEnglish(file)); } Is there a good implementation of getReasonForFileDeletionFailureInPlainEnglish(file) already out there? Or else I'll just have to write it myself. ...

include dependencies into jar

Hi, is there a way to force maven(2.0.9) to include all the dependencies into jar file? I have a project the builds into a single jar file. I want that the classes from dependencies will be copied as well. Update: I know that I cant just include a jar file into a jar file. I'm searching for a way to unpack the jars that are specified as ...

java beans: difference between persistent field and persistent property?

I got the impression that if we use persistent fields, there is no need for getter methods since the entity manager references the instance variables directly. However, when I removed the getter and setter methods from an entity to have persistent fields, the values for the corresponding instance variable was not retrieved from the datab...

How do I work with the Card Layout in the NetBeans GUI builder?

Does anyone know how to work with the Card Layout in the NetBeans GUI builder tool? I want to show panels as per the JRadioButton selection, so I want to lay this out using the Card Layout. ...

ICEFaces inputFile getting the file content without upload

Is there any way of just getting the content of the browsed file without any upload/file transfer operations? I currently use ICEFaces inputFile component but I do not need the default uploading operation of the file. Thanks. ...

Matching between char sequences - first occurence before

I have a string like: "This is AA and this is AA and this is AA and this is the END blah blah" I want to match: "AA and this is the END" ie, ending in END, back to the first occurance of AA before END. (Language is Java) ...

SpringJunit4ClassRunner -- can I change the lifetime of the injected resources?

By experiment, I find that SpringJunit4ClassRunner treats the context and its beans as 'class scope' in the JUnit sense of scope. It inititializes my beans once for the entire set of tests in the class. Is there any way to use this mechanism and get these things to be 'test scope'? In short, I wish that the context was being loaded as @...

How to get remote debugging work for Java on Solaris

Hello, I am trying to get remote debugging working with Java on Solaris OS. Following is what I have tried- I have a Java class called TestP which has the main method. When I try java -classpath . TestP the program works fine. But when I try adding the debug parameters to the JVM- java -Xdebug -Xrunjdwp:transport=dt_socket,address=...

How to change table background depending on database textareas 'height' ?

Is it possible to get the height of a 'text' field from mysql? Or the number of linebreaks would also work! I have a table which fetches the 'text' field from my mysql database. The background image of the table is sort of a container... I want the background to change to another (taller) background if the text is vertically high! Poss...

Spring schemaLocation fails when there is no internet connection

Hi I am using Spring and at application-context.xml file; i have definations like : <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springfram...

How to start the java console when launching an application from Eclipse?

When I start a java application, the Java Console is started. But when I start a java application from Eclipse, the Java Console does not start on its own. How can I make it start also when I run an application from Eclipse? ...

ArrayList to Table in JSP

I have an ArrayList and i am trying to display it in a table ..... ArrayList rows = .... ..... <table cellspacing="1" cellpadding="4" border="3"> <tr> <TH> Heading1 </TH> <TH> Heading2 </TH> <TH> Heading3 ...

JFreeChart in scrollpane

Hi, I'm having a big graph created with jfreechart. This chart is too big for the screen, so I would like to put it in a scrollpane. However, when using the scrollbar, the complete graph is redrawn everytime, which makes it extremely slow. Is there a solution for this? thanks, Bart ...

Adding jar from eclipse plugin runtime tab

I want to add .jar files for plugin from the Runtime tab of manifest file. When I use the add button, I can see only sub-directories of the plugin project. So if I want to add same .jar file to more than one plugin project where should I store the .jar files. ...

ehcache persist to disk issues

I want to do something with ehcache in Java that I think should be extremely simple, but I've spent enough time frustrating myself with the docs... Write a value to a disk persistent cache. Shut down. Start up again and read that value. Here is my Java function: private static void testCacheWrite() { // create the cache manager fr...

Hibernate does not generate identifier when using Oracle sequence

I have the following mapping @Entity @SequenceGenerator(name="sacpSequenceGenerator", sequenceName="SACP_SEQ") public class Sacp { private Integer id; @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="sacpSequenceGenerator") public Integer getId() { return this.id; } // other setter's a...