java

In Java, why does untyped call of constructor of parameterised type provoke compiler warning?

In Java, why does an untyped invocation of a constructor of parameterised type provoke a compiler warning? Why is it okay to do similar thing with a static method? For example: class Test<T> { Test() {} static <T> Test<T> create() { return new Test<T>(); } @SuppressWarnings("unused") public static void m...

Java Replacing multiple different substring in a string at once (or in the most efficient way)

I need to replace many different sub-string in a string in the most efficient way. is there another way other then the brute force way of replacing each field using string.replace ? ...

Will struts 1.2.4 work with Java5 ?

As of now we are using Struts1.2.4 with java4. We want to upgrade it to Java5. Java 5 has so many deprecated method in EE. Will struts 1.2.4 work with java 5? ...

How to bypass JDBC statement cache in concurrent batch processing?

I'm developing a server that should receive nightly reports from hundreds of business units. Reports are currently encrypted csv-files. In total the reports should amount to 500 000 to 1 000 000 records each day that are saved to a database for later use. I've create a set of PreparedStatements for each transmission. These statements ar...

How to give JSP permissions with SecurityManager policy file in Resin?

We are trying to use SecurityManager with Resin 3.1.9 and run into the following problem: CodeSource.getLocation() returns null for compiled JSPs. This means that we cannot use a specific codebase in grant clause in our policy file, for example: grant codeBase "file:/path_to_resin/runtime/work/-" { OR grant codeBase "file:/path_to_resi...

Setting java system properties to a java application.

Hi, What i'm trying to do, eventually, is to start TOMCAT with certain java system properties set (in this case jmx setup): -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9898 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false` ) Problem is I don't think i'm doing it right...

Render to BufferedImage in Java3D

Is there a simple way of rendering to a BufferedImage in Java3D? I know you can extend Canvas3D, but it seems cumbersome if I just want to render directly. ...

Java 6 NTLM proxy authentication and HTTPS - has anyone got it to work?

I have a Java application (not an applet) that needs to access a web service. Proxies for the web service have been generated with JAX-WS, and seem to work fine. In one scenario it needs to talk through a web proxy server (actually Squid 3.0), which is set to require NTLM authentication. Running on Sun's JRE 1.6.0_14, everything works f...

Should I use Security Manager in Java web applications?

Is it sufficient to secure a Java web application with the rights of the user that is running the application server process or is it reasonable also to use SecurityManager with a suitable policy file? I have used to do the former and not the latter, but some customers would like us to also use SecurityManager that would explicitly give...

How to detect Out Of Memory condition?

I have an application running on Websphere Application Server 6.0 and it crashes nearly every day because of Out-Of-Memory. From verbose GC is certain there are the memory leaks(many of them) Unfortunately the application is provided by external vendor and getting things fixed is slow & painful process. As part of the process I need to...

How can I get client infomation such as OS and browser

I'm using JSP, Servlet to develop my web application. I want to get client information such as: operation system, browser, resolution, ... whenever a client is using my website. ...

How to run Red5 applications on a remote server?

I've got a really nasty problem... I wrote a Red5 app and so on and it is running perfectly on my local computer. Now the problem occurs => How can I make this program work on a remote server? Local : Mac OS X 10.5 - Red5 0.63 Server: CentOS 5 - Red5 0.90 Maybe it's because of the version difference. But I can't test Red5 0.90 loc...

How to execute IN() SQL queries with Spring's JDBCTemplate effectivly?

Hi all together, i was wondering if there is a more elegant way to do IN() queries with Spring's JDBCTemplate. Currently i do something like that: StringBuilder jobTypeInClauseBuilder = new StringBuilder(); for(int i = 0; i < jobTypes.length; i++) { Type jobType = jobTypes[i]; if(i != 0) { jobTypeInClauseBuilder.append(','); } ...

What does this Regular expression do?

I'm in the processing of converting a program from Perl to Java. I have come across the line my ($title) = ($info{$host} =~ /^\s*\(([^\)]+)\)\s*$/); I'm not very good with regular expressions but from what I can tell this is matching something in the string $info{$host} to the regular expression ^\s*(([^)]+))\s*$ and assigning the mat...

Common practices if we discover a problem after deploying a web application?

I recently have a problem that my java code works perfectly ok on my local machine, however it just wouldn't work when I deploy it onto the web server, especially the DB part. The worst part is that the server is not my machine. So I had to come back and forth to check the versions of softwares, the db accounts, the settings, and so on.....

How can I parse a date including timezone with Joda Time

This snippet of code always parses the date into the current timezone, and not into the timezone in the string being parsed. final DateTimeFormatter df = DateTimeFormat.forPattern("EEE MMM dd HH:mm:ss 'GMT'Z yyyy"); final DateTime dateTime = df.parseDateTime("Mon Aug 24 12:36:46 GMT+1000 2009"); System.out.println("dateTime = " + d...

Inspecting java class instance variable values in Eclipse

In an application, I have a class with a few member variables and methods. Calling the method with bad parameters produces a AssertionError. I've setup the debugger to halt on uncaught exceptions. Problem is, when switching over to the debug perspective, I can only see the class instance (on which the function was called) and the two pa...

j2me application doesn't work on Mobile Phone

I have developed one simple application in J2ME. Application just do simple HttpConnection and make only request. Here is the code for that : public void run() { System.out.println("Inside saveData"); HttpConnection hc = null; OutputStream dout = null; try { System.out.println("custName = " + custName); ...

Should I cache the return value of a getter if it is just a simple delegate?

For example: I'm creating a CSV file and I have a CsvOptions object which holds several parameters for the CSV file creation. if (cells.hasNext()) { output.write(csvOptions.getDelimiter()); } The csvOptions is just a simple container object, that kind you are tempted to not use any getters at all. The getter just returns the valu...

SWT Browser Problem on Vista

We're running Java Swing and are using an SWT bridge to get ahold of the SWT browser. Everything normally works just fine, but we have a problem on a Vista test machine. It worked fine until just a week ago or so. The call stack: org.eclipse.swt.SWTError: No more handles at org.eclipse.swt.SWT.error(SWT.java:3589) at org.eclipse...