java

help needed in selector issue nio, threading

I need to implement a server in which has only one selector(static); multiple threads try to register channel to the same static selector. I tried to implement the server, but the problem is that the static selector works for first time i.e. registers the channel; but on next call to register different channel the thread gets hanged. I...

How do I get the correct starting/ending locations of a xml tag with SAX?

There is a Locator in SAX, and it keep track of the current location. However, when I call it in my startElement(), it always returns me the ending location of the xml tag. How can I get the starting location of the tag? Is there any way to gracefully solve this problem? ...

Receive input from mute/play/stop/etc. on front of Dell Inspiron laptop

I have a Dell Inspiron E1505 and as you can see in this image it has some buttons on the front for mute, play/pause, stop, volume control, etc. The mute and volume buttons actually affect the volume settings for the computer itself, but the others can also be used to control some other applications, such as Windows Media Player and even ...

JEE - find session size

Is there a way to programatically track the size of a particular session on a JEE app server, or do I have to resort to the app server's vendor specific instrumentation to do this? Two scenarios: Track from within the application (a sort of JMX-type interface) Track from without (outside) - a generic piece of code that works on all ap...

Sieve of Eratosthenes problem: handling really big numbers.

I'm solving Sphere's Online Judge Prime Generator using the Sieve of Eratosthenes. My code works for the test case provided. But.. as the problem clearly states: The input begins with the number t of test cases in a single line (t<=10). In each of the next t lines there are two numbers m and n (1 <= m <= n <= 1000000000, n-...

web grabber

in java how the url is downloaded and save it in to a local directory. More over i want a offline view of that downloaded url(especially the html content). ...

remove allfile option in jFilechosser java

Hi, i'm using swings jfilechooser in program,i want it to filter files with .txt extension,and it is showing allfiles option also in window,so i want to remove allfiles option,how can i do it plz help me this is my code: fc1 = new JFileChooser(); fc1.setMultiSelectionEnabled(true); // Allow for multiple selections fc1.setCurrentDire...

Problem in Custom tag in JSP

Hi i have a custom tag in JSP <dc:drawMultiSelect availableLabel='<%=request.getAttribute("availableCoreColumn").toString()%>' selectedLabel='<%=request.getAttribute("selectedCoreColumns").toString()%>' availableCName="selectCol" selectedCName="selectedCol" availableCId="select1" selectedCId="select2" sort...

OutputStream delete file contents JAVA

I have files in who i need to record serialized object. I open ObjectOutputStream for writing in files. If i didnt wrote nothing in file, file content get deleted. I don't want content to be deleted when i make ObjectOutputStream. Any help? Edit: @Provides @ArticleSerializationOutputStream public ObjectOutputStream getArticleObjectOutp...

What to do when java.util is missing on a Mac

This is kind of weired but my Mac/Eclipse isn't offering me any java.util classes. I am still able to run the project which contains heavy use of (let's say) Vector, but I am not able to add a new Vector in the code anywhere. Eclipse isn't offereing me... I spent the last night reconfiguering the installed JRE's and build path etc. but...

Java ScriptEngine: using value on Java side ?

In a Java program I'm invoking a user-defined JavaScript program: File userJSFile=...; javax.script.ScriptEngineManager mgr=new ScriptEngineManager(); javax.script.ScriptEngine scripEngine= mgr.getEngineByExtension("js"); Object result=scripEngine.eval(new java.io.FileReader(userJSFile)); Now I would like to use 'result': how can I h...

How do I maintain session state with a Google Earth client?

I'm playing with dynamic updates to Google Earth KML files. The updates are of the form <kml...> <NetworkLinkControl> <Update> <targetHref="..."> <Change> <Placemark targetId="..."> ...stuff to update... </Placemark> </Change> </Update> </NetworkLinkControl> </kml> And it all work...

pattern match java: does not work

hey everyone, i am trying to find a certain tag in a html-page with java. all i know is what kind of tag (div, span ...) and the id ... i dunno how it looks, how many whitespaces are where or what else is in the tag ... so i thought about using pattern matching and i have the following code: // <tag[any character may be there or not]id...

How to take single snapshots from a webcam?

Hello, I want to take a snapshot with my webcam using java and save it to a jpg file. What are the steps needed to do so? A tutorial would be greatly appreciated. Greetings, Burkhard ...

What remoting approach for Java application would you recommend?

I wonder how is the best way to integrate Java modules developed as separate J(2)EE applications. Each of those modules exposes Java interfaces. The POJO entities (Hibernate) are being used along with those Java interfaces, there is no DTO objects. What would be the best way to integrate those modules i.e. one module calling the other mo...

How to use Javas Polygon class with lat,longs

Hi, I have two geo-spatial simple convex polygon areas, in latitudes and longitudes (decimal degrees) that I want to compute using Javas Polygon class. I basically want to see if these two lat,long polygons intersect, and to calculate the areas (in sq meters) of both. Now java.awt.Polygon class only uses x,y co-ordinate system, but I ne...

Using JSON serialization as a persistence mechanism instead of RDB

I'm thinking about throwing away my DB in my next project to simplify development/evolution. One way to do it is not to leave the Objects realm at all and persist my objects by some kind of serialization. It would be nice to be able to edit the initial objecs state when the app is down, so format like Json would be great. The problem i...

Check if BigDecimal is integer value

Can anyone recommend an efficient way of determining whether a BigDecimal is an integer value in the mathematical sense? At present I have the following code: private boolean isIntegerValue(BigDecimal bd) { boolean ret; try { bd.toBigIntegerExact(); ret = true; } catch (ArithmeticException ex) { ret...

Spring Security UserDetails Best Practice

I am using my own implementation of the UserDetailsService interface to load a User object from the Database and place it as UserDetail into my SecurityContext. The User object is then a detached Hibernate object. When I want to access lazy load relations of the authenticated User I need to get it from the SecurityContext and attach it ...

JTable multiple filter design paradigm

As title says, i wonder if you could you direct me to some document, or give me advice here, on designing (GUI design) form which main part is occupied by jtable, which has several filters.Main goal is to avoid visual clutter. ...