java

java thread blocking

Can non synchronized methods called from synchronized methods allow a thread to block? public synchronized void foo(){ someStuff(); someMoreStuff(); bar(); } public void bar(){ //... does some things } If a thread is executing foo() is there anyway to ensure that bar() will be called before the thread sleeps? TIA ...

How can I find out if a File is a file or directory if it does not exist?

File.isFile() and File.isDirectory() both return false not only when the File is not the specified type, but also when the File itself does not exist on the filesystem. How can I determine whether the File represents a file or a directory when it does not exist? ...

buildr: package dependencies into a single jar

I have a java project that is built with buildr and that has some external dependencies: repositories.remote << "http://www.ibiblio.org/maven2" repositories.remote << "http://packages.example/" define "myproject" do compile.options.target = '1.5' project.version = "1.0.0" compile.with 'dependency:dependency-xy:jar:1.2.3' compil...

Your views about the gap between naming convention of field names in Java bean and database

Hi, In many past projects, I observed that people tend to keep database column name as two or three words separated with '_', for example : first_name. However the same column is mapped to Java bean's variable : firstName. I don't know why people don't keep database field names like firstName but tend to use _ in between. Even if we us...

What is perm space?

While learning about java memory profiling, I keep seeing the term "perm space" in addition to "heap." I know what the heap is - what's perm space? ...

Remove Specific Plot Key Entries in JFreeChart

I have an XYPlot in JFreeChart with multiple XYDatasets. JFreeChart creates a key at the bottom of the plot with an entry for each series by default. I would like to disable the drawing of entries for all of the series in one of my datasets. I do not want to disable the drawing of entries altogether. Is this possible without modifyin...

Truncating a list to a given number of elements in java

There is any method to truncate a list in java, for example, to the first 100 elements, discarding the others? (I mean, without iterating and/or copying/deleting elements one by one) ...

Does Hibernate's Criteria API still not support nested relations

I'd like to use Hibernate's Criteria API for precisely what everybody says is probably its most likely use case, applying complex search criteria. Problem is, the table that I want to query against is not composed entirely of primitive values, but partially from other objects, and I need to query against those object's id's. I found th...

How to execute a java .class from the command line

I have a compiled java class: Echo.class public class Echo { public static void main (String[] arg) { System.out.println(arg[0]); } } I cd to the directory and enter java Echo "hello" I get this error: C:\Documents and Settings\joe\My Documents\projects\Misc\bin>java Echo "hello" Exception in thread "main" java...

GWT Incubator Glass Panel not implementing ClickHandler

Hi everyone, I have an app that uses the GWT-Incubator GlassPanel class. I extended it to form a custom one that implemented a ClickListener. I upgraded to GWT1.7 and GWT-Incubator 1.7, and it broke ClickListener. I tried to rewrite my class so that it implemented ClickHandler, but it does not execute my new onClick method when the p...

What are the common tricks in eclipse when working with jsp files?

I looked through this list of “Hidden” features/tricks for Eclipse?", but it doesn't have anything for web-developement (jsp). A very useful list of tricks for a general eclipse user! I work with jsp pages in Eclipse Ganymede, and I would like to find out a list of shortcuts commonly used to facilitate development. I always seem to str...

I don't understand getNextIncludedTime() in Quartz

I'm probably just being an idiot - it's been a long day! I've misunderstood something in my first foray into Quartz... Given this code: DateTime dt = new DateTime(); dt = dt.withDayOfMonth(20); Calendar cal = new CronCalendar("0 0/10 * * * ?" ); long start = dt.getMillis(); System.out.println("Starting at " + start); long end = start ...

Monitoring application-specific metrics using JMX and Hyperic

My webapp exposes some application-specific metrics (think "orders placed") via JMX, which I'd like to monitor using Hyperic HQ (open source edition). According to the Hyperic Inventory Model, my Linux server is called a Platform hosting my Tomcat 6 Server, which in turn hosts Services (e.g. "Servlet Monitor"), who finally expose Metric...

Program output lost when passed through PsExec

(This is a question my coworker posted elsewhere, but I thought I'd post it here to see if I could hit a different audience.) Hello all, I'm testing the possibility of writing a small java application the will use Psexec to kick off remote jobs. In the course of testing binding the stdin and stdout of a java program to psexec I came ac...

How does this normalize function work?

I was doing a Junit tutorial and I came across this normalize function that was being tested. It was defined like this: public static String normalizeWord(String word) { try { int i; Class<?> normalizerClass = Class.forName("java.text.Normalizer"); Class<?> normalizerFormClass = null; ...

Glassfish JNDI Tree Linking

Hello, We are using Glassfish v2 (9.1_02) at work. Our servers are not set up in a clustered environment. We would like to have one main server as a JNDI server that can serve DataSource objects, and possibly other objects in the future, and link other servers to this one server. This way, if we change the location of a database or cha...

Dynamic xml filtering and transform (in Java)

I have an XML file that looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name="foo1" value="bar1" /> <node name="foo2" value="bar2" /> </root> I have a method String processBar(String bar) and I want to end up with <?xml version='1.0' encoding='UTF-8'?> <root> <node name="foo1" value="proc...

Trying to bring swing frame to front before taking a screenshot but getting artifacts

I have a part of my app that takes a screenshot of a certain window but before I do so I want to bring the window to the front. This works fine on my Mac machine but when I tested it on in Windows XP on paralells the screenshot always has a greyed out area where the overlapping window was. It seems the screenshot is always taken while ...

JRadioButton border/padding/insets/margin... whatever you call it

In my Java app I am trying to create a very simple form with a label and a set of controls on each row of the form. Imagine something like this crude ASCII diagram: Result 1: (*) pass ( ) fail Result 2: ( ) pass (*) fail Error Count: [10______] Explanation: [Operator overload___] Annoyingly the JRadioButtons don't line up wit...

@Autowired and TransactionProxyFactoryBean?

I have a repository class that is created in XML like so: <bean id="stuffRepositoryTarget" class="my.stuff.RepositoryImpl"> <!-- some params --> </bean> <bean id="stuffRepository" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" primary="true"> <property name="target" ref="stuffRepositoryTarget" /> <...