java

How do I bundle multiple modules and 3rd-party JARs in a ZIP using Maven2?

I'm developing my application as a set of OSGi bundles using Maven 2. Some common functionality, such as logging, web server etc. is used from other OSGi bundles, for example, I'm using the OSGi version of Jetty. I want to ship my application with all third-party bundles and an OSGi container included. I chose Apache Felix as my default...

Find closest value in an ordererd list

Hi all, I am wondering how you would write a simple java method finding the closet Integer to a given value in a sorted Integer list. Here is my first attempt: public class Closest { private static List<Integer> integers = new ArrayList<Integer>(); static { for (int i = 0; i <= 10; i++) { integers.add(Integer.valu...

Ant run command with pipes

I must to implement command : java -jar test.jar page.xml | mysql -u user -p base in ant. So i Have tried with this task: <java jar="test.jar" fork="true"> <arg line="page.xml | mysql -u user -p base"/> </java> But i have got en exception with pipe - "|" : java.lang.IllegalArgumentException: Input already set; can't set to | So,...

Why is the order of declarations important for static initializers?

I have this code private static Set<String> myField; static { myField = new HashSet<String>(); myField.add("test"); } and it works. But when I flip the order, I get an illegal forward reference error. static { myField = new HashSet<String>(); myField.add("test"); // illegal forward reference } private static Set<St...

How to start bluetooth pairing process?

I have an Java application on my PC and database.There are some MAC and PIN data in DB. I'm sending messages (now it's text files over OBEX put method, but in future it will be SMS messages i hope :) ), so when i discover some device, then discover needed service i'm looking to the DB and if the phone MAC in the DB i need to start ...

Connection Exception trying to send email in Java

Hello. I am using the Javamail API to try and send an email in my java code. The problem is occurring on a particular line. Part of the code is: URLConnection c = u.openConnection(); c.setDoInput(false); c.setDoOutput(true); c.connect(); The error is occurring at the c.connect() line of t...

Does the contents of rt.jar change across different JVM vendors?

Hi, I've inheirited support for a legacy web app which is directly using the **.internal.** apache xerces classes within the rt.jar. I think the history is that this code (back in java1.4) used to explicitly use xerces and at some point when moving to java5 use of the xerces jar was dropped and those classes were referenced out of rt.ja...

java.io.StreamTokenizer.TT_NUMBER: Floating or Integer ?

Hi all is there a way to find if the value parsed and returned by java.io.StreamTokenizer.nval (e.g. 200) was an integer or a floating number ? Thanks Edited: I want to be able to know if the input was '200' or '200.0'. ...

How do I find all the methods that have specific parameters with reflection?

I need to find all the methods in a class that accept a set of parameters in a specific order, some of them are generics (Collection). The example on the Sun web site only works with non generic classes: http://java.sun.com/docs/books/tutorial/reflect/member/methodInvocation.html cheers in advance ...

How to transition from OO development to Web-Development?

I just graduated last year and I landed a job in the CRM space, specifically with Salesforce.com and its respective platform. My problem is that there are 2 languages used to do things on this platform one is relatively similar to java and is OO the other is a web-development language similar to js, but not quite. I come from a java ba...

Define Implementation for abstract Object

I am looking for a way to do the following: A Project : Defines an abstract class that is called when some events happen (event handler if you will) Defines the engine that will fire the events using the event handler above B Project: Defines the implementation for the abstract class Runs the engine. How can i register the implementa...

How to implement the Observer pattern with Java RMI?

I have a client that starts a long running process on the server. At regular intervals, I'd like to show the user what's happening in the background. The most simple approach is to poll the server but I'm wondering if there wasn't a way to implement the Observer pattern for this. Unfortunately, I'm using RMI to talk to the server and I f...

Quartz JobStore with Spring Framework

Hi all, I am implementing Quartz Job Store on Oracle DB using Spring Framework. My ApplicationContext.xml is below <bean id="driverJob" class="org.springframework.scheduling.quartz.JobDetailBean"> <property name="jobClass" value="BatchFileCollector" /> </bean> <bean id="ranchTrigger" class="org.springframework.scheduling.quartz.Simple...

free OCR library

can any one suggest a free ocr library dot net or java for me. I needto convert images containing text to word documents. The input images will be of tyy .tiff,.gif,.bmp.jpg. ...

JSF authentication and authorization

What is the best way to go about implementing authentication and authorization for a JSF web application? Preferrably I'd still want to use container-based security, as I need to call EJBs that require the principal. I realize form-based authentication is a major struggle with JSF, but can I perhaps use a PhaseListener or something simi...

Firebird vs HSQLDB at Java

Hi , i wanna write a small (5-6 table) desktop app in java.I wanna use Firebird 2.1. database.But i googled and see HSQLDB.I wanna make a decision between firebird and hsqldb :) So which database i have to use ? ...

strace java applet

I'm trying to strace a java applet, and strace doesn't seem to be working. I'm calling the following function. public static void testSTrace(){ long c = 0; for (int i = 0; i < 1000; i++){ long start = System.nanoTime(); try{Thread.sleep(0, 100);}catch(Exception e){/*cry*/} long stop = System.nanoTime(); log.info("start : " ...

Turn off tomcat logging

I want to turn off tomcat's logs jvm.stderr and jvm.stdout which have been set in the wrapper.properties, I've commented these lines out but that just redirects the logs to be written to the root tomcat folder. The reason for turning them off is that these logs do not seem to have any sort of size control so I have a situation where th...

a CSS class for Java

I'm about creating a java class for parsing and storing the content of a simple CSS stylesheet. This class will be used to paint a non-html object using the CSS selectors. My naive approach is to basically use a Map<String,Map<String,Object>> to store this stylesheet. Would it be any (clever) other way for storing this information ? ...

Application Configuration (Spring?)

Hi Stackoverflow! im getting tierd of all this boring boilerplate code to parse application configuration like database connections, working directories, API endpoints and whatnot. Sping IoC looks nice, but this will force the user of my application to modify the XML file just to edit the database URL and so on. This might also be very ...