java

Java: Why does a 512-bit RSA KeyPairGenerator return 65 byte keys?

Hello, this is somewhat a newbie question probably. I'm generating keypairs with Java: KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN"); keyGen.initialize(512, random); KeyPair keyPair = keyGen.genKeyPair(); RSAPrivateKey privateKey = (RSAPrivateKey)keyPai...

How to get notification about EJB deployment (to set up a timer)?

Hi community, I'm deploying an EJB which should set a timer and be triggered by it every 24 hours. But where should I set the timer? @PostConstruct does not help -- this is a session bean, so post-construct method will be invoked when the actual instance is created (this never happens as the sole purpose of this bean is to track timer)....

Problem creating bean of sessionFactory in spring-hibernate configuration

Hello, I am using spring and hibernate for configuration with mysql db. My we.xml file has following code : <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun....

Manipulating Videos using Java Media Framework

How would I go about manipulating a video stream with Java Media Framework, for example; the user loads a video, and then can adjust the brightness/contrast while the video is playing. ...

Arranging triangles in grid order

My program generated triangles automatically, however the arrangement of the triangles are random on JPanel. How can I plot the triangle in a grid order? Thanks. EDITED: for(int i = 0; i < 10; i++) { xCoord[0] = generator.nextInt(MAX_WIDTH); yCoord[0] = generator.nextInt(MAX_HEIGHT); xCoord[1] = (int) (xCoord[0] - xWidth);...

Google MultiMap and synchronization

Hi, I dont understand why i get a concurrentModificationException when i iterate trough this multimap. I read the following javadoc entry, but i'm not sure to understand the whole thing. I tried to add synchronized block. But i doubt on what to synchronize with, and when. Dont hesite to be crude if do huge mystake with concurency ;-)...

How do I programmatically obtain the version in JBoss AS 5.1?

Does anyone know how to programmatically obtain the server version number under JBossAS 5.1? JBossAS 4.2 had org.jboss.Version, with getMajor() and getMinor() methods, but this doesn't seem to exist in 5.1. ...

How to avoid a NoRouteToHostException?

Disclosure: the code I'm working on is for university coursework. Background: The task I'm trying to complete is to report on the effect of different threading techniques. To do this I have written several classes which respond to a request from a client using Java Sockets. The idea is to flood the server with requests and report on how...

How often will a function be called in a ternary operator?

I have this line of Java code: return getValue() != null ? getValue() : 0 How often will getValue be executed? Once or twice? EDIT: If this is compiler-dependant, I'm especially interested in the compiler from the Sun JDK. ...

Overloaded method selection based on the parameter's real type

Hi community, I'm experimenting with this code: interface Callee { public void foo(Object o); public void foo(String s); public void foo(Integer i); } class CalleeImpl implements Callee public void foo(Object o) { logger.debug("foo(Object o)"); } public void foo(String s) { logger.debug("foo(\"...

Question about CronTrigger - Quartz

Concerning http://www.opensymphony.com/quartz/wikidocs/CronTriggers%20Tutorial.html .. given bunch of examples and I just don't get this, how would I write CronTrigger expression to run every minute of every day for unlimited amount of time. I've "figured" out about running it every second which is easy "* * * * * ?" how would I write ex...

Java based web framework alternatives

Hello, I'm trying to pick a web framework that is Java based to start a new project and so far I'm having a bit of trouble deciding. I have been using plain GWT and I have to say that is very good, the architecture, the APIs and the docs are all very good, but I lack the knowledge to apply CSS and prettify my widgets, so I need somethin...

Importing a schema LDIF and content LDIF on every startup of ApacheDS?

Hi guys! I want my embedded ApacheDS to start up with a fresh schema/content when I run my tests. I tried to import a LDIF with this lines: LdifFileLoader ldifLoader = new LdifFileLoader(service.getAdminSession(), "path/to/my/export.ldif"); ldifLoader.execute(); But now ApacheDS stores the information in a directory server-wo...

Java Fast Data Storage & Retrieval

I need to store records into a persistant storage and retrieve it on demand. The requirement is as follows - Extremely fast retrieval and insertion Each record will have a unique key. This key will be used to retrieve the record The data stored should be persistent i.e. should be available upon JVM restart A separate process would move...

Accent and case insensitive collation in Oracle with LIKE

Hi, I have found this answer useful: Accent and case insensitive COLLATE equivalent in Oracle, but my question is regarding LIKE searching with a version 9 Oracle db. I have tried a query like this: SELECT column_name FROM table_name WHERE NLSSORT(column_name, 'NLS_SORT = Latin_AI') LIKE NLSSORT('%somethingInDB%', 'NLS_SORT = Latin_AI...

What are the JNDI dependencies?

Hi, we are wanting to use a JNDI service with our client applications (all written in Java SE 6) and here is our doubt: what are the dependencies? Does the JVM already comes with all the classes that we'll need to access these services? If not, where can we get them? ...

Is conversion to String using ("" + <int value>) bad practice?

Is conversion to String in Java using "" + <int value> bad practice? Does it have any drawbacks compared to String.valueOf(...)? Code example: int i = 25; return "" + i; vs: int i = 25; return String.valueOf(i); Update: (from comment) And what about Integer.toString(int i) compared to String.valueOf(...)? ...

What's the default heap size for IBM's J9VM?

I have IBM's J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3) installed. After getting an OOM, the size of the heap dump is 383MB. How much heap does the JVM have? The reason why I ask is that a 400MB heap dump seems a bit much for the default 64MB heap that I expect but I didn't specify any -Xm options. Does J9 use a different default heap siz...

Java, xml, XSLT: Prevent DTD-Validation

I use the Java (6) XML-Api to apply a xslt transformation on a html-document from the web. This document is wellformed xhtml and so contains a valid DTD-Spec (<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;). Now a problem occurs: Uppon transformation the XSLT-...

EJB Authentication and Authorization

Is there any way to extend the authentication operation which connects a client application to an EJB, using standard JAAS/container-based security? I'm looking for a way to use more than just a username to authenticate the user (in this case a domain name is also needed). Ideally I'd like to be able to use the SessionContext.getCallerPr...