java

Why does getRealPath() return null when deployed with a .war file?

Hi, getRealPath() is returning the actual path in the local system, but returns null when deployed with a .war file. <%@ page import="java.io.*" %> <%@ page contentType="text/html;charset=ISO-8859-1" %> <% int iLf = 10; char cLf = (char)iLf; String a= application.getResource("/"); //String myfile = application.getRealPath("/")+ "gener...

C++ slicing in Java / C#

Can C++ slicing apply to other languages too, like Java/C#? ...

Is it a good way to use java.util.concurrent.FutureTask ?

First of all, I must say that I am quite new to the API java.util.concurrent, so maybe what I am doing is completely wrong. What do I want to do? I have a Java application that basically runs 2 separate processing (called myFirstProcess, mySecondProcess), but these processing must be run at the same time. So, I tried to do that: publ...

User Variable's value in environment variables is not getting during runtime while running jar application from window service?

Hi All : I have used a method "System.getenv();" to get a value of user defined environment variable in jar application. I have made the jar application to run from window service. But when i try to start the service, it is not getting user defined environment variable's value and showing null pointer exception. I have tried with System ...

Cannot refer to the static enum field within an initializer ?

I just got Java5 project that has this error, i tried using Java5 and Java6, but its still there. it worked somehow before(since it was in svn), how can i bypass that compiler error? ...

Java simple String diff util

Hi, I'm looking for a simple java lib/src to highlight differences between two Strings, case-sensitive. A html output would be great, but I would be happy to get the indexes of the diffs, something like: diff("abcd","aacd") > [2,2] diff("maniac", "brainiac") > ["man",brain"] or [0,3] or something like that The idea is to higlight ty...

Updated item info in container, how do I refresh?

I'm going out on a limb here, and hoping that someone has used IT Mill Toolkit before: I have a Table with a bunch of Items inside. I edit one of them – how do I get the Table to refresh and re-render itself? I've tried with requestRepaint(), requestRepaintAll() on both the table, and the Layout that contains the Table, but I can't get ...

Doubt in exception handling and finally block in java

Can you tell the idea of how to doing it? Code : public void main(String[] args) { try { //Some Exception throws here } catch(SomeException se) { se.printStackTrace(); } finally { try { //SomeException1 throws here } catch(SomeException1 se1) { se.prin...

Combining UrlRewriteFilter and struts 2 with get parameters

Following up on an older question of mine, I managed to get URL Rewriting working somewhat correctly for my struts project where URLs like search?q=blah get converted to queries search.action?q=blah. We use UrlRewriteFilter for this. This seems to forward fine to struts (if making sure it has a filter mapping with FORWARD), but when the ...

Do I have to recompile my application when I upgrade a third party jar?

I have a java application that uses some third party API. The third party jar files change fairly frequently because of all kinds of patches, but the API itself does not change that often. Do I have to recompile my application every time the third party jar changes? ...

How to connect to a secure website using SSL in Java with a pkcs12 file?

I have a pkcs12 file. I need to use this to connect to a webpage using https protocol. I came across some code where in order to connect to a secure web page i need to set the following system properties: System.setProperty("javax.net.ssl.trustStore", "myTrustStore"); System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); S...

Accessing an outer anonymous class's field from an inner anonymous class

To access the field x of an outer class A from an inner class B, I realize that you can use "A.this.x". But what if the outer class is also anonymous? For example, public class Main1 { public static void main(String[] args) { Comparable c1 = new Comparable(){ int x = 3; public int compareTo(Object o)...

Putting char into a java string for each N characters

I have a java string, which has a variable length. I need to put the piece "<br>" into the string, say each 10 characters. For example this is my string: `this is my string which I need to modify...I love stackoverlow:)` How can I obtain this string?: `this is my<br> string wh<br>ich I nee<br>d to modif<br>y...I love<br> stackove...

Performance / stability of a Memory Mapped file - Native or MappedByteBuffer - vs. plain ol' FileOutputStream

I support a legacy Java application that uses flat files (plain text) for persistence. Due to the nature of the application, the size of these files can reach 100s MB per day, and often the limiting factor in application performance is file IO. Currently, the application uses a plain ol' java.io.FileOutputStream to write data to disk. ...

"Screen" effect in Java 2D graphics

This is a question that's been bugging me for some time now: In photoshop/GIMP, there is a "screen" layer composition mode. This mode has bright colours have a strong alpha, and dark colours a weak one. Black is entirely transparent, white entirely opaque. I would dearly love to be able to replicate this composite using Java 2D graphic...

Limitations with Java Hotswap

The java hotswap feature save a lot of time for me. However, it has many limitations (like schema change is not supported). Any idea if the limitation is going to be addressed any sooner? According to this forum entry, it seems to be ignored. I know that products like JavaRebel helps. But does anyone know about any open source tools for...

How can I include more than one path on a custom docletpath?

I have a javadoc doclet that requires an additional jar file to be on the doclet's classpath. To run the doclet from the command line, I do something like this: java com.sun.tools.javadoc.Main -doclet myPackage.myDoclet -docletpath /path/to/doclet/classes When I run that, it finds the doclet on the path and executes it, but the docle...

Sourceforge daily builds

I currently mantain an open-source project hosted in SourceForge. My project is written in Java using ANT build scripts. (Ant has a few extensions installed, but let's ignore that for now.) Unfortunately, there seems to be no easy way to automatically generate daily builds. Is there any workaround I can use. Here is what I want: It sh...

Which sector of software industry uses C++?

Like most people, I learnt C++ after C. I learnt C++ because it was one of those languages which fetched jobs. I am still studying (doing masters) though. One of my cousins has been working as a developer for around 12 years. He advises me to learn Java so that I can land up in a good job. He says only few sectors like tele communicatio...

How to create encrypted Jar file?

I am working on project that must need to protect data (revealing code is not main problem) files. We are using Java + Netbeans. Is there any facility that will create jar in encrypted format? We are also using sqlite for database - so putting text file in encrypted format is not proper option for us too. ...