java

what is the most efficient way of reading a log file in java?

What is the most efficient(fast and safe) way of reading a log file in java? The log file continuously(almost every second) gets updated. ...

Jetspeed preferences not being loaded

Hello, I'm attempting to upgrade a web application I'm working on from Java 1.5.0_06 to Java 1.6.0_16 and I've run into a problem concerning Jetspeed, the web portal I'm using. Basically, I set some preferences for a certain portlet in my portlet.xml file, but it seems they're not being loaded. The relevant portion of my portlet.xml f...

How to @link to a Enum Value using Javadoc

Using Javadoc 1.5, I have been unable to create a @link to an Enumeration value. What I would like to do is to create an Enum like this: public enum Planet { /** * MERCURY is a fun place. */ MERCURY, /** * VENUS is more fun. */ VENUS, /** * But nothing beats the Earth. */ EARTH, /** * Others we know nothing about. */ OTHERS } ...

OQL for finding new objects only in heap dumps?

Does anyone know the OQL syntax for finding new objects only in a heap output? I can't find good documentation on OQL options, sun even has an example of new-only output without sample syntax of the query that generated it.What I've done is Created a set of heaps with jhat Served them up with jmap -baseline, which marks objects not in ...

What’s the best profanity filter which supports Java integration?

What is the best profanity filter (free / open source or paid commercial) which supports Java integration? It needs to be able to take a string and return a clean string... Can be a web service and doesn't necessarily have to support Java... Happy programming... ...

can not import inbuilt java class file (javax.naming.ldap.SortControl)

I have downloaded Openfire sources and started to run it on Eclipse. I got a error saying javax.naming.ldap.SortControl class is not there, as illustrated on the following image: . Since it is inbuilt Java class , what can i do to solve this problem. Full source has about 5 error messages, all of them are saying the same. ...

Splitting words into letters in Java

How can you split a word to its constituent letters? Example of code which is not working class Test { public static void main( String[] args) { String[] result = "Stack Me 123 Heppa1 oeu".split("\\a"); // output shou...

where/how to setup configuration resources for Tomcat .war files

I have a source tree for a .war file that I need to modify so that I can add some application-specific configuration info (in this case a jdbc connection string, but I may have other properties-like resources). What are the best practices for where to put configuration info and how to access this from within the Servlet? I'm guessing th...

TextMate for Java/Maven development

Is anybody doing Java/Maven development with TextMate? Any Bundle I can use for it? I am aware of regular bundles for Maven and Java (to generate part of the code), but are there are any bundles to help list classes methods? (like Eclipse/Netbeans/etc. does). And not the current class methods, but say I have FirstDemo.java which has meth...

In Java 1.6, why does adding a Jpanel to another JPanel using the default add() not display the added panel?

I have a JFrame with a JPanel on it. I want to add another JPanel which is a preconfigured component onto the Jpanel inside my JFrame. If I do this: subPanel.setLayout(new BorderLayout()); subPanel.add(preconfiguredPanel,BorderLayout.CENTER); my Panel will show. If I do this: subPanel.add(preconfiguredPanel); my JPan...

Validation of interrelated fields

We have a validation system which forces users to select from a valid set of values across a set of inter-related fields. The user has to fill in the first value in the list, and whichever value they have selected determines which set of values they will be able to select from in the second field. Their choice of value in the second fi...

Getting index number in Java

How can you get the index number in Java? Example which is not working class masi { public static void main( String[] args ) { char[] list = {'m', 'e', 'y'}; // should print 1 System.out.println( list[] == "e" ); ...

Which is the standard Java crypto API?

Hi, I want to implement a tool in Java to learn more about cryptography. I know that there is a security package with some crypto stuff inside. Now I saw there is a dedicated javax.crypto package inside the SDK. Where is the difference? Are they both up to date? I wanted to start my tool with some historical ciphers. But it should n...

Java to Ruby (Base64/SHA1) public digest generation

Give a public key, I want to generate a public digest. Below is the code in JSP, but I need this in Ruby. I'm uncertain of the equivalents of SecretKeySpec, doFinal, etc. I'm using hmac, and hmac-sha1 on the Ruby end of things. String pub = 'my_public_key'; BASE64Encoder encoder = new BASE64Encoder(); Mac sha1Mac = Mac.getInstance("Hmac...

Obtaining a list of all classes used while running a Java application?

What is the easiest way to obtain a list of all classes used while running a Java application? Assume that com.package.Foo.main is invoked by running: java com.package.Foo After running the program I'd like to have a list of all classes that have been used while running the program: cat classes-used.txt com.package.Foo com.package.F...

How to programatically know when a JButton's text is truncated?

I need to know when the text for a JButton is truncated by the layout. So, in order to find out I am overriding the following method in our custom ButtonUI delegate: protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) { //the text argument will show an ellipse (...) when truncated } Inside the meth...

Does Input/OutputStreams close on destruction?

Does InputStreams and OutputStreams in Java close() on destruction? I fully understand that this may be bad form (esp in C and C++ world), but I'm curious. Also, suppose I have the following code: private void foo() { final string file = "bar.txt"; Properties p = new Properties(); p.load( new FileInputStream(file) ); //...

How to redirect all console output to a Swing JTextArea/JTextPane with the right encoding?

Hi, I've been trying to redirect System.out PrintStream to a JTextPane. This works fine, except for the encoding of special locale characters. I found a lot of documentation about it (see for ex. mindprod encoding page), but I'm still fighting with it. Similar questions were posted in StackOverFlow, but the encoding wasn't addressed as...

Interesting AOP question on a cross cutting concern?

Consider a set of DOAs with methods similar to this public void addObject(Long sessionId, Long clientId, Dom obj){...} Now every domain pojo (Dom) has a sessionId property and for every insert, update or delete on a domain object a sessionId must be passed with setSessionId(Long sessionId)so we can know who does what. But it seems tha...

Java and SDL_GetKeyState()

I'm trying to convert to Java some code that uses SDL. I'm using the sdljava bindings. sdljava uses SWIG as the bridge between the C datatypes and Java. To get the equivalent of SDL_GetKeyState(), sdljava provides the method SWIG_SDLEvent.SDL_GetKeyState(), which returns something called a SWIGTYPE_p_unsigned_char. Of course, Java has...