java

Follow Up: Create an an array of objects from classname

Hello, I am following up on this question, 1268817 In the question, we find a way to create an isntance of an object given a the name (as a string) of the class. But what about to create an array of those objects... how would one initialize that. I was thinking something in the line of but doesnt seem to work Object[] xyz = Class....

Scala: public static final in a class

I'm trying to get a real equivalent for Java's public static final in Scala for using TwiP. Creating a val in an object don't works for me, because it's part of a new generated class Example$.class and TwiP can't access it from class Example.class. Here's an example of a Java Class I'm trying to port to Scala: public static final Stri...

TransactionProxyFactoryBean when switching from configuration-based Service beans to annotation based service beans

Hi guys, I read about using <context:component-scan base-package="tld.mydomain.business"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/> </context:component-scan> and annotate my service beans with @Service("myService"), and thought great, I'll do that, since I'm already doi...

sync entitymanager from database

Hi. i have a swing desktop application that use a entitymanagerfactory, but when this application is executed many times at the same time, the diferents entity managers have old data that was modified by others and this changes will not visible until the next entitymanagerfactory... how can i sync in anytime the entitymanager with the da...

Get battery level in Java

I would like to make a java app that shows the current battery level of my mac OS X. I have read http://stackoverflow.com/questions/25552/using-java-to-get-os-level-system-information and was wondering how I could modify this to make it display the current % of battery Thanks ...

Passing pointers between C and Java through JNI

At the moment, i'm trying to create a Java-application which uses CUDA-functionality. The connection between CUDA and Java works fine, but i've got another problem and wanted to ask, if my thoughts about it are correct. When i call a native function from Java, i pass some data to it, the functions calculates something and returns a resu...

Java Scheduled Executor: Does it guarantee to not run in paralell if task hast not yet finished

Hello, does anyone know if the following java Method in the java.util.concurrent Package ScheduledExecutorService.html#scheduleAtFixedRate() absolutely guarantees, that the Runnable scheduled will never run in parallel in case the runnable from the "last" run did not yet finish: For example (Pseudocode) 1.00 o'clock: scheduleAtFixedR...

Redirect with Curl/HttpClient: header "Location" missing.

Hi all, when I get the following url with curl curl -D headers.http "http://www.springerlink.com/index/10.1007/s00453-007-9157-8" the file headers.http contains a "Location" header: HTTP/1.1 302 Found Date: Tue, 27 Oct 2009 17:00:20 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Location: http://www.s...

What is the best approach for having some kind of lazy iterator where the return is evaluated only on request?

import java.util.Collection; import example.Event; public interface Query { public boolean hasMore (); public Collection<Event> getNext ( long count ) throws Exception; } This is the interface I have, which I want to implement. The implementation is supposed to be like this: import java.util.ArrayList; import java.util.Col...

Globally accessible resources in Wicket application

Currently, I have an Application which consists of a BasePage which as a header (panel), footer(panel) and in the center for inherited page content. The problem I am running into is with ResourceReferences (Perhaps this isn't even the right way). I am looking for a solution which will allow me to do the following: Have a single direct...

Can you do Vector addition in Java, natively?

I Know there's a "Vector" class in java, but it seems to be just a simpler ArrayList type of deal, not an actual, mathematical Vector (as in a magnitude and a direction). Is there any way to do Vector manipulations (particularly addition) in Java? Or am I stuck on my own having to implement it or use a third party module? -Jenny ...

Architecture Concerns

My domain classes and persistance logic (Hibernate) are in one project called model. This jar is included within all of my apps. Packaged com.company.model & com.company.persistance Another Utils.jar - contains DateTime, String, Thread, etc general helper classes. This again is included within all of my apps. Packaged com.company.utils ...

Java: JProgressBar

Hi, Is it possible to make a progressbar in Java like displayed on this page? Image.So, not the default progressbar "filling-way". If so, how? Thanks ...

parent child relation in composite object ?

I have a composite object (tree) with parent-child relationships.The tree can be upto n levels (say for e.g 10-12 levels) Now suppose i have to remove an object at level 6 in the hierarchy.If i point its reference to null (while leaving the child object untouched) in Java then what happens to the child objects under it (do they become a...

Java Code Formatting in Textmate

Is there a way/bundle/shortcut to format the Java Source in TextMate? (As we do with Shift+Command+F in Eclipse). ...

Java methods that look like: public static <F extends Field<F>> DenseVector<F> valueOf(F... elements)...what are they?

So, I'm looking through a java library (JScience) after someone here thoughfully pointed me towards it for getting Vectors (mathematical ones, that is) in java. Unfortunately, I've never seen anything in my life before like: public static <F extends Field<F>> DenseVector<F> valueOf(F... elements) as a method you can call in the Dense...

is there a way to generate a Content-Type header from a file extension in Java?

I have a Java application which sometimes has to generate a Content-Type header from a filename alone. Is there a way to estimate the Content-Type for common extensions? (e.g. ".pdf" maps to "application/pdf", etc) ...

if a JAR is placed on app servers's classpath how do we reference it from JSP

On our application we are getting an error saying: PWC6117: File "/struts-tags" not found code in the file thats giving error is: <%@ taglib prefix="s" uri="/struts-tags" %> This file is in struts2-core.jar which is placed on the classpath of the app server (Sun 9.1). The code will work fine and not complain when the jar is actual...

What is this syntax in Java? I do not recognize it.

This is a syntax question. I was looking at some open source files and I met some syntax that I cannot recognize and I was hoping you could clear it up for me. (This is taken from the Main.java in the Rhino debugger here) public static String[] processOptions(String args[]) { String usageError; goodUsage: for (int...

Java KeyAdapter

I am somewhat unfamiliar with how the Java KeyAdapter works, and am getting unexpected results with the following code using KeyAdapter. The problem occurs when a key is pressed while another key is already held down, regardless of whether isKeyPressed() is called. Note: I know this is a lot of code, and I apologize. I tried the best I ...