java

Eclipse (Pulsar) packaging: How do I incorporate other projects into my jar?

I have a JavaME project in Eclipse (Pulsar 3.5; Galileo). I have another project with common code in it in the same workspace and this is referenced from my app. When I choose 'package app' it generates a jad/jar in the project's deployed folder, but the classes from the referenced project are not included. Is it possible to include t...

Behaviour of final static method

I have been playing around with modifiers with static method and came across a weird behaviour. As we know, static methods cannot be overridden, as they are associated with class rather than instance. So if I have the below snippet, it compiles fine //Snippet 1 - Compiles fine public class A{ static void ts(){} } class B extends...

Can I run jrunscript from a JRE

The JDK has jrunscript executables. Does the JRE have the needed jars that can be executed so as not to require a complete JDK to use jrunscript? In other words, can I run jrunscript by calling the java executable with a class name. ...

Java: cannot parse and display non-utf8 characters read from an http request

Hello, I'm using Java to parse this request http://ajax.googleapis.com/ajax/services/search/web?start=0&amp;rsz=large&amp;v=1.0&amp;q=rz+img+news+recordid+border which has as a result this (truncated for the sake of brevity) JSON file: {"responseData":{"results": <...> "visibleUrl":"www.coolcook.net", "cacheUrl":"http://www.google....

Best way to get maximum Date value in java?

I'm writing a bit of logic that requires treating null dates as meaning forever in the future (the date in question is an expiration date, which may or may not exist). Instead of putting in special cases for a null date throughout the code, I want to just convert null into the maximum possible Date. I don't see any obvious ways to get su...

How to use jaxb 2 in a web application within Oracle Application Server

I have an application that is running Jaxb 2.1.12. I am running JDK 1.5 and OC4J 10.1.3.4.0. When I try to use the portion of my application that is using Jaxb, I get the following error: Unable to locate jaxb.properties for package I narrowed this down to the xml.jar that comes with OC4J. It contains Jaxb 1.0 classes. I can fix this ...

How to keep up to date on available Java libraries?

I've been writing java.io code verbosely for far too long, and stumbled onto Apache Commons IO last week. I've used a lot of Commons before, but never looked at IO, and now I feel silly for writing a notable amount of extra code over the years. Is there any good resource for Java libraries that isn't overwhelming, besides maybe reading...

Optimizing the creation of objects inside loops

Which of the following would be more optimal on a Java 6 HotSpot VM? final Map<Foo,Bar> map = new HashMap<Foo,Bar>(someNotSoLargeNumber); for (int i = 0; i < someLargeNumber; i++) { doSomethingWithMap(map); map.clear(); } or final int someNotSoLargeNumber = ...; for (int i = 0; i < someLargeNumber; i++) { final Map<Foo,Bar>...

How do I get the InputStream of decompressed data from an InputStream of GZIPed data?

I call a service which returns a gzipped file. I have the data as an InputStream (courtesy of javax.activation.DataHandler.getInputStream();) from the response. What I would like to do is, without writing anything to disk, get an InputStream of the decompressed data in the file that is in the archive. The compressed file in this case i...

Reading XML file prepared for JAR when testing application in Eclipse

I'm writing a small app with the help of Eclipse while learning Swing GUIs in Java. I'm also taking my first baby steps in Ant build scripting and have come across a small problem. I'm parsing an XML file to create objects to store in a List. I've assigned the Ant build script to include the XML file in the Jar package by adding this to...

parse log file - using java and plot graph

I am writing a log analyzer program which is supposed to plot a graph on search string against time after parsing log file(s). I am currently clueless about how would I parse and store the log file so that it could be processed to create multiple outputs, now I am parsing the entire log file all the time and process to do this – any sugg...

How to check which images/css/javascript are used in web app?

The other day I found this little piece of software - WARI. It stands for Web Application REsource Inspector. Apparently it checks dependencies between css, html, js and images and reports unused and duplicated css styles, javascript functions and images. Link: WARI is released! What do you use? Any alternatives? ...

JNA/ByteBuffer not getting freed and causing C heap to run out of memory

Let me start by saying that my understanding of how JNA and Java direct native memory allocations is visceral at best, so I'm trying to describe my understanding of what's going on. Any corrections in addition to responses would be great... I'm running an application that mixes Java and C native code using JNA and am running accross a ...

Help translating this Java codeblock to Clojure?

I'm getting my feet wet with Clojure, and trying to get used to functional programming. I've been translating various imperative functions from other languages into their Clojure equivalents -- and so far everything has been going well. However, I've now run into a sticking point and I have no idea how to translate this Java method int...

How to attach a file to an email using JavaMail

I need to send a PDF file using JavaMail. The PDF is currently a byte[]. How do I get it into the DataSource? byte[] pdffile = .... messageBodyPart = new MimeBodyPart(); DataSource source = ??? messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(filename); multipart.addBodyPart(messageBodyPart); ...

Display Problem with absolutepanel with gwt-connector

Hi, I am trying to use GWT-Connector in one of my classes to create the connection point to the widgets. Here is what i have: public class Test extends Composite{ RequiredData rd = new RequiredData(); public Test(){ TextBox t1 = new TextBox(); t1.setSize("100px", "20px"); t1.setText("Hi"); t1.setTitle("textbox"); CustomSh...

Errors running Coldfusion 9 under Liferay 5.2 to serve portlets

So this all began in trying to get Coldfusion9 portlets to run under Liferay, just like examples that I've seen running JBOSS: http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSC00E3E9C-DC24-4488-930D-AEED19172CC5.html I followed those steps, but my application server would be TomCat 5.5 (bundled w Liferay 5.2.3). I wanted to cre...

how can the PL/SQL datatype BINARY_INTEGER materialized as Java types?

What would be the datatype in java equivalent to the PL/SQL datatype BINARY_INTEGER? ...

Are there any memory utlization issue with JAXB?

I am using JAXB for xml parsing, are there any performance or memory utilization issues? ...

How to create a development/debug and production setup

Hello there, I recently deployed inadvertently a debug version of our game typrX (typing races at www.typrx.com - try it it's fun). It was quickly corrected but I know it may happen again. After digging on Google I found some info how to create 2 different profiles, one for development mode that has the debug functions and one used...