java

Sun App Server Deployment Error

Sun App Server Deployment : When choose to precompile JSP : Throw this error com.sun.enterprise.admin.common.exception.MBeanConfigException: Component not registered then have to do asadmin undeploy Anyone know what is the reason for this error? ...

User Login in Java - JAAS/JNDI/GSSAPI

What is the best way to design a user login mechanism using Java? What are the best practices to be followed to architect a secure and robust login mechanism? What is the difference between JAAS, JNDI and GSSAPI? How do you decide which one to choose? ...

Read environment variables from file in Windows Batch (cmd.exe)

I'm trying to read variables from a batch file for later use in the batch script, which is a Java launcher. I'd ideally like to have the same format for the settings file on all platforms (Unix, Windows), and also be a valid Java Properties file. That is, it should look like this: setting1=Value1 setting2=Value2 ... Is it possible to ...

Boundary for comment box

In my java application, I need to create a comment box for the users to add comments. Moreover, I need to provide the user with the provision for resizing and dragging the comment box. For this, I need to show a boundary around the comment box as in the case of comment box in Microsoft Excel which I have shown below: I dont need the c...

How to extracts additional info from SSL certificate to allow access to WebService client on WAS

For explaining my situation, I will start with an example. Let's say there are two WS(WebService) clients A & B with trusted certificates. Now in normal excecution when both A & B make a call to WAS(Websphere application server) through SSL where my WebServices reside, WAS trusts both of them because of their trusted certificates and alo...

AWT TextArea seems to count cr-lf sequence as one character

I have this problem: The text "ABCD\r\nEFGHJ" loaded from a file is matched with java regex "EFGH". Matcher object of course says start of the matched string is in position 6. The matcher counts \r \n as two positions. I put the original text in a AWT TextArea Component and then call select(6,10) to highlight the area which was matched...

What is the best way to do GUIs in Clojure?

What is the best way to do GUIs in Clojure? Is there an example of some functional Swing or SWT wrapper? Or some integration with JavaFX declarative GUI description which could be easily wrapped to s-expressions using some macrology? Any tutorials? ...

Deploying EAR file in Sun App Server having problem with proxy server setttings

When I am deploying certain vendor EAR file to Sun App Server, I encountered a connection timeout errror. I thought the reason might be proxy settings need to be defined so I actually defined the following -Dhttp.proxyHost=hostname -Dhttp.proxyPassword=password -Dhttp.proxyPort=8080 -Dhttp.proxyUser=username After setting these and res...

How to mock classes instantiated as local variables

I'm writing tests for a business method that invokes some DAO classes to perform operations over a database. This method, firstly retrieves a JDBC connection from a DataSource object, The same connection is passed to all DAO instances, so I can use it to control the transaction. So, if everything works properly, I must invoke commit() o...

Java L&F customization: How do I use synth to customize BorderFactory borders?

Specifically, I currently have a JPanel with a TitledBorder. I want to customize the look of the border. In my app's current state, the title is drawn, but not the line border itself. If I bind an imagePainter to the panelBorder method for Panel objects, I can put a custom image around panels -- however it only shows up on those panels ...

Write dpi metadata to a jpeg image in Java

I am trying to programatically set the dpi metadata of an jpeg image in Java. The source of the image is a scanner, so I get the horizontal/vertical resolution from TWAIN, along with the image raw data. I'd like to save this info for better print results. Here's the code I have so far. It saves the raw image (byteArray) to a JPEG file, ...

Closures in Java 7

I have heard that closures could be introduced in the next Java standard that is scheduled to be released somewhere around next summer. What would this syntax look like? I read somewhere that introducing closures in java is a bigger change than generic was in java 5. Is this true? pros and cons? (By now we definitely know that closur...

Can Eclipse Be Used To Find All Deprecated Method Calls?

Does Eclipse have a feature that lets you search a project to find all calls to deprecated methods? ...

cache FreeMarker templates

Hi, I'm using the Spring class FreeMarkerConfigurationFactoryBean to retrieve FreeMarker templates. I would like these templates to be cached, but there doesn't appear to be any way to indicate that this behaviour is required. In contrast, Spring modules provides a CachingTemplateResolver which does provide template caching, but is it ...

Should Java raw types be deprecated?

Should a future release of Java deprecate the use of raw types to force the migration to generics? I could also see having raw types not allowed by default but allowing them via a compile flag for legacy code. ...

Colorize logs in eclipse console

Is there a way to colorize parts of logs in the eclipse console. I know I could send to error and standard streams and color them differently but I'm more looking someting in the lines of ANSI escape codes (or anyother, HTML ?) where I could embed the colors in the string to have it colored in the logs. It sure would help making the im...

Spring + Tiles2 + Freemarker - integrate via Freemarker Servlet or via Spring's FreeMarkerViewResolver?

Hi all, i was strugling today trying to migrate from Freemarker to Tiles2 + Freemarker. My freemarker templates use macros that come from spring.ftl. If i provide a fremarker servlet in web.xml, my model is visible to freemarker, but specific spring variables (naturally) are not populated into the model as springs FreemarkerView is r...

How to pass parameter to servlet

How do I pass a parameter from a page's useBean in JSP to a servlet in Java? I have some data in a form that gets passed no problem with a submit button, but no way to send anything else. Please help? Here is my code: <input name = "deleteGameButton" type = "submit" value = "Delete" onclick = "submitToServlet('DeleteGameServlet');"> ...

Can anyone explain servlet mapping?

I'm trying to write a web application using SpringMVC. Normally I'd just map some made-up file extension to Spring's front controller and live happily, but this time I'm going for REST-like URLs, with no file-name extensions. Mapping everything under my context path to the front controller (let's call it "app") means I should take care ...

Java file extension regex

Hi, I'm trying to come up with a Java regex that will match a filename only if it has a valid extension. For example it should match "foo.bar" and "foo.b", but neither "foo." nor "foo". I've written the following test program public static void main(String[] args) { Pattern fileExtensionPattern = Pattern.compile("\\.\\w+\\z"); bo...