java

Simple Server Monitoring with Java

I'm trying to find a solution that allows me to monitor resource consumption of a server. Preferably, the metrics I'm wanting to obtain are network utilisation IO, and if possible CPU usage/load average and disk IO. The only other requirement I have is that this information be obtainable by Java so it can be manipulated, and at least wo...

How to configure my log4j ( using Glassfish ) to log in the logs directory, not in config?

Hi, I have the following line in my log4j.properties file: log4j.appender.logfile.File=MyApplication.log My log file appears in MyDomain/config directory, but I would like it to land in the MyDomain/logs directory. How can I achieve that? I am not allowed to modify the startserv script. Thanks in advance for your help! ...

How to reduce size of RTF with embedded images?

Hi, We have some code which produces an RTF document from a RTF template. It is basically doing string search and replaces of special tags within the RTF file. This is accessible via a web page. Typically, the processing time for this is really quick. However, we need to embed an image within a template. We've been embedding these ...

Is there a Java 1.4 library that returns time in microseconds?

I was wondering if there was a Java 1.4 library that would return a higher precision time value than your trusted Date.getTime() millisecond value, something similar to System.nanoTime() but for a JDK 1.4? A custom JNI with C++ QueryPerformanceCounter is the only solution, or something like this has been done before and can be reused? ...

How to create my installer which will be cross platform in java

Hi I want to create a cross platform installer in java. How to create. Thanks Sunil Kumar Sahoo ...

Tomcat: Set cookie value multiple times for 1 request?

I'm running into a problem with Apache Tomcat 6.0.20 where I can't change a cookie's value once it has been added to the response. Basically, I'm trying to replicate Session functionality using cookies. I have a custom "Session" object, which is backed by a cookie. When I create my Session, I pass it an HttpServletResponse, and it cre...

Load XML files into Oracle XML DB Repository (java)

Has anyone ever used Java to take XML files on one machine and put them an Oracle XML DB Repository that is on another machine? Did you use WebDAV, HTTP, FTP? Does anyone have insight into this? Thanks! ...

Java JDBC: Reply.fill()

Hi, I get the following exception at times: com.ibm.db2.jcc.b.gm: [jcc][t4][2030][11211][3.50.152] A communication error occurred during operations on the connection's underlying socket, socket input stream, or socket output stream. Error location: Reply.fill(). Message: Connection reset. ERRORCODE=-4499, SQLSTATE=08001 The proble...

Release multiple locks atomically in Java

If I have acquired a number of locks, how do I release the Set of locks atomically? ...

How to created an instance of Internet Explorer in java by using JExplorer?

I want to access IE functionality like click, navigate, forward, backward, filling a form etc. through java by using JEXplorer. Kindly show me the code or the link to the code. ...

Autocomplete Parameter names in Eclipse Without Source

I am working with a proprietary library that has JavaDocs, but no source code. I've attached the JavaDocs to the library's jar, but I still can't get useful parameter names auto-completed (they are named arg0, arg1, arg2, etc). Is there any way to fix this without source code? ...

how to handle NAT traversal in c++ peer to peer application ( please code examples not theory )

Hello all i need to develop simple game that will be using peer to peer connection using centralize index manger server i know there is problem when client trying to connect other client behind router . i was reading about NAT traversal that explain mainly theory , but what i really like to see is code examples c++/java can you help m...

Is there a Java method that encodes a collection of parameters as a URL query component?

Is there a widely-used Java library that does something like what dojo.objectToQuery() does? E.g. (assuming the use of HttpCore's HttpParams object, but any key-value mapping will do): HttpParams params = new BasicHttpParams() .setParameter("foo", "bar") .setParameter("thud", "grunt"); UnknownLibrary.toQueryString(params); sho...

Wrapping Booleans in Objects

I have some code that I want to refactor. I have lots of methods that take multiple arguments of the same type, for example: public void foo(String name, String street, boolean b1, boolean b2) { ... } and so on. Because the different objects can only be distinguished by name I would like to wrap them in Objects (Enums) so I can make u...

Access user session objects from another thread, how to make it?

How can I access a user session objects from another thread? I want to delete some users on a regular basis. I can just delete them from the database, but some user can be logged in. So I want to invalidate his session if its exists. How can I find and invalidate his session using his userId? As I understand a servlet container has som...

SSO between Liferay 5.2 and PHP through CAS

I'm trying to use CAS for SSO between Liferay and a PHP webapp. I installed JASIG CAS webapp, created a certificate with keytools and configured Liferay through its administrative GUI (Setting>Authentication>CAS tab) as follows: When I click on "Sign in" in Liferay menu I'm forwarded to the CAS login page (with the "dirty trick" user...

What encoding to use for exporting to CSV?

I'm developing a java app that exports data to CSV files, intended to be opened in Excel by end users. We just noticed that the export function uses Java's platform default encoding. This causes umlaut characters to be lost and unit test to fail on the build server (which is configured to have US-ASCII as its platform default encoding ex...

Starting Tomcat with remote debugging (jdwp) when installed as a windows service

I have a Tomcat installed as a Windows service. I'd like to configure it to support remote debugging via jdwp. When starting it from the command line (catalina.bat), I can add this string to allow debugging: -agentlib:jdwp=transport=dt_socket,suspend=n,server=y,address=10000 Where can I added jdwp support when running it as a windows...

java, convert windows path to dos 8.3 format.

anyone knows any java utility method that would convert windows paths to DOS 8.3 format ? thanks ...

Run Java Application as a Service

I would like to run a Java application as a service. Unfortunately, I am limited in that I can't use something like the Java Service Wrapper (which does appear to be an excellent tool). Is there any way of running an executable JAR, as a service, without relying on external applications? I currently have the service installed, but it ...