java

Scale numbers to be <= 255?

I have cells for whom the numeric value can be anything between 0 and Integer.MAX_VALUE. I would like to color code these cells correspondingly. If the value = 0, then r = 0. If the value is Integer.MAX_VALUE, then r = 255. But what about the values in between? I'm thinking I need a function whose limit as x => Integer.MAX_VALUE is 25...

Which Java Service or Daemon framework would you recommend?

I have encountered many different ways to turn a Java program into a Windows Service or a *nix daemon, such as Java Service Wrapper, Apache Commons Daemon, and so on. Barring licensing concerns (such as JSW's GPL or pay dual-license), and more advanced features, which one would you recommend? All I intend to do is convert a simple Java p...

openfire smack lib

does smark library support all jabber server? or only can be use for openfire? i looking for java library that is easily portable to any jabber server ...

Under what situations will Java's field.setAccessible(true) fail?

I have a situation where a user's code is throwing an IllegalAccessException on a field accessed by reflection. Just before accessing the field, setAccessible(true) is called. So, it would seem to me that this method is silently failing. Under what situations would this happen? Could this have something to do with a security manager...

Is there a limit on the number of exceptions I should throw from a method?

this is my function declaration public init(){ try{ initApplication(); }catch(A1Exception){ }catch(A2Exception){ ... }catch(A5Exception){ } } private void initApplication() throws A1Exception, A2Exception, A3Exception, A4Exception, A5Exception { initApp1(); //throws A1, A2, A3 initApp2(); ...

shutdown hook for java web application

I need to save some data preferrably when the java web application is stopped, or when tomcat is stopped. how can this be done? Edit: any drawback if I use the jvm shutdown hook? ...

Threads in a J2EE application

I have a J2EE application that has two components: First is a service that scrapes some information from internet and fills it into database. Second is a web interface (deployed on tomcat) from where user can browse that information. What could be the best approach to implement the first component? Should it be run as a background Daemo...

Libraries/Solutions for using XSL to create interactive web forms from XML

This seems like a pretty straightforward thing to do, but I can't find anything off the open-source shelf. Is there a solution already out there that does the following: can be configured with an arbitrary XSL stylesheet generates a web form based on an arbitrary XML document and the XSL creates edit functionality in appropriate place...

Font name not found on Linux

In Java I have code that works well on OSX but not in linux. This code loads a font file and uses Font.createFont(). Here's the code: log.debug("Loading ttf file AmericanTypewriter.ttf"); InputStream americanTypewriterInputStream = MyClass.class.getClassLoader().getResourceAsStream("AmericanTypewriter.ttf"); log.debug("File AmericanType...

SiteMapPath Asp.net at Java

Hello, how can i do SiteMapPath navigation like Asp.net at Java (home -> product -> dvd -> ...) Exist some lib or jar to do it ? Or some example, would be nice, any idea ) Thank you. Thank you CraigTP :) ...

Hibernate QueryException couldn't resolve property

I have this .hbm.xml file : Evenement.hbm.xml : <hibernate-mapping package="com.af.evenement"> <class name="Evenement" table="TB_EVENEMENT"> <id name="id" type="string" column="CODE_EVENEMENT"> <generator class="assigned" /> </id> <set name="causesAnnexes"> <...

Pause a SourceDataLine playback

I want to play back WAV sound (audio track of some custom video format) in Java, however, I have trouble using Clip for that: it seems only one instance is hearable at a time. Therefore, I switchet to the plain old SourceDataLine way. In this context, I want to pause and resume the audio as the video is paused and unpaused. Unfortunatel...

how to add menu to section title?

Hi, I have a section with TITLE_BAR, and i try to add a menu to the section header (like in the PDE editors). All I could find is the context menu. ...

Trimming whitespace from HTML content?

I have a CRUD maintenance screen with a custom rich text editor control (FCKEditor actually) and the program extracts the formatted text as HTML from the control for saving to the database. However, part of our standards is that leading and trailing whitespace needs to be stripped from the content before saving, so I have to remove extra...

Java-Sockets: InputStream.read() vs BufferedReader.read()

Hello I'm reading from a Socket's InputStream. Because I'm parsing the incoming data on the fly, I'm required to read character by character. Does BufferedReader.read() the same thing as InputStream.read() does ? (assuming that BufferedReader has been constructed with the InputStream as base) Is it more efficient to use InputStream.re...

How do I get the style of the selected text in a JTextPane?

I'm trying to create a simple WYSIWYG editor that will allow users to select text and bold/underline/italicise it. Currently the user can select text, right-click it and select bold from a popup menu, which ends up applying the bold style to the selected text like so: this.getStyledDocument().setCharacterAttributes(this.getSelectionStar...

Android Image Viewer from App

I'm trying to launch an image which is written to my application directory with the builtin Android image viewer. This image has been written in a different part of the app to the app directory. When getting the following file: super.getFilesDir() + "/current.png" File.exists() returns true. How can i launch the builtin Android image ...

creating jar file

can some one explain me how to crate jar file. my source folder has various sub folders and image files. you can see images explaining source folder structure from following url http://img63.imageshack.us/gal.php?g=capturev.png. when jar is created using eclipse export jar function, it only include class files only , but i want to crea...

Find all the keywords of java language and the names of the java API classes

Hi, I want to ask you a question.I am not sure I will get any answers but I will give it try:) As the header says, I need a way(e.g a file from sun's website) that contains all the keywords of the java language and also the class names of the java API.I know that there is some way, as the compiler has this list on his disposal but I do...

C++ and Java performance

Hi, this question is just speculative. I have the following implementation in C++: using namespace std; void testvector(int x) { vector<string> v; char aux[20]; int a = x * 2000; int z = a + 2000; string s("X-"); for (int i = a; i < z; i++) { sprintf(aux, "%d", i); v.push_back(s + aux); } } int main() { for ...