java

String data passed to Java Applet by javascript is null when in Java applet

This question may look familliar but I've discovered some rather more pertinent information and tried some other things (which are detailed below) so to avoid confusion I've created another question. Here's the JavaScript (on an aspx page): function CallApplet(clientRef, system, branch, category, pdfXML) { AppletReturnValue...

Discovering clients on a wifi network

I'm writting a java application, and I need to quickly discover any other running clients on any wired or wireless local networks in order to establish a TCP connection. what's the best way of doing this? Are there libraries or code snippets that would do this? ...

Renaming a file using Java

Can we rename a file say test.txt to test1.txt? What if test1.txt exists will it rename? How do I rename it to the already existing test1.txt file so the new contents of test.txt are added to it for later use? ...

Easiest Way to Check if a Java String Instance Might Hold Spam Data.

Hi, I have a process which iterates String instances. Each iteration does few operations on the String instance. At the end the String instance is persisted. Now, I want to add for each iteration a check if the String instance might be spam. I only have to verify that the String instance is not "adult materials" spam. Any recommendat...

One-To-Many child has already been persisted without parent

I'm using the Google App Engine in combination with the Google Web Toolkit to write a bug tracker (to see what the technologies are capable of). Modelled after Google Code's issue tracker, I decided that an issue can have 0 or more labels, that can be defined beforehand (let's say in the settings). The label class (CustomLabel): @Pers...

Where is Java source code for various com.sun.* packages on Leopard?

I am working on my MacBook at home, running Leopard, with the latest JDK 1.6 from Apple installed. In IDE, I'd like to browse source code for com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel, but IDE cannot find it. Another example I'd like to browse is com.sun.java.swing.plaf.nimbus.ButtonPainter. What JAR or ZIP do I need to add to my...

How to use login callback for application client.

I'm writing a Swing application client (it's runs over webstart, and I'm using glassfish). In the application class I have: @EJB private static MyBean myBean; and in MyBean I have: @Remote public interface MyBean { public int getRand(); } @DeclareRoles(("admin")) @Stateful(name="MyBean") public class MyBeanImpl implements MyBean {...

Inlining in Java

In C++ I can declare a method "inline" and the compiler is likely to inline it. As far as I understand there is no such keyword in Java. Inlining is done if the JVM decides to do so? Can I influence this decision somehow? ...

Understanding Classes

I'm new to programming and have some questions about classes. I'll use Karel as an example: public class Karel extends robot{ .... } then I extend Karel: public class SuperKarel extends Karel{ .... } but then I want to organize some groups of methods: public class KarelJumps extends SuperKarel { .... } public class ...

Should one call .close() on HttpServletResponse.getOutputStream()/.getWriter() ?

I couldn't find an authoritative answer to this with some Googling. In Java servlets, one can access the response body via response.getOutputStream() or response.getWriter(). Should one call .close() on this stream after it has been written to? On the one hand, there is the Blochian exhortation to always close output streams. On the oth...

Oracle Java Stored Procedure Command-line Interaction

I have a funny requirement. We need to have a command-line interaction in a Java Stored Procedure. In spite of granting appropriate permissions using the dbms_java.grant_permission commands, I am encountering java.io.IOException, where I read from System.in using java.io.InputStreamReader. Where is the problem? The Java Source is here...

How do I set the Java library path from a Java task?

Is it possible to specify a library path in a java task? Like the equivalent of: java -Djava.library.path=somedir Whatever ...

Span/Grow bug in MigLayout?

The following is close to what I want, and does what I expect: import javax.swing.JComboBox; import javax.swing.JPanel; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import net.miginfocom.swing.MigLayout; public class MigBug extends JFrame { public static void main(String args[]) { M...

Java, "bind" something to a Thread

Hi, I was just wonderhing how some libraries can detect in which thread they run and "bind" something to it... for example the Mapped Diagnostic Context (MDC) of log4j or Context.enter() from Mozilla Rhino. How could i do that, just in case i'll stumble upon a case where i need this. ;-) Have a nice day! ...

Is there a good and reliable open source Java package to get free stock info ?

I used to use my Java programs to get free stock data (historical prices, charts, current prices ...) from Yahoo, but recently it stopped working, because Yahoo doesn't seem to welcome people systematically getting data that way. So I wonder if there is any good (reliable and kept up-to-date) open source Java packages that get free stock...

get possible instance/type of object

I have the problem that a given object could be one of several different objects (like files in a directory, that could be sound, image, text, ...) Is there the possibility to find out the type of the object beside from the 'instanceof' operator? Couse that would result in an endless if - then row ... ...

ibatis ibator Java code generation problem

I use ibator eclipse plugin 1.2.1. My RDBMS is MySQL 5.1. I have a ibator config file as shown below: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE ibatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Apache iBATIS Ibator Configuration 1.0//EN" "http://ibatis.apache.org/dtd/ibator-config_1_0.dtd" > <ibatorConfigura...

Faces on WAS 6.1

Hello, I'm running Java Facets on a IBM WebSphere 6.1. I'm getting this strange error message when I start the server: [2009-07-21 15:49:35:784 CEST] 00000015 ServletWrappe E SRVE0100E: Did not realize init() exception thrown by servlet Faces Servlet: java.lang.IllegalStateException: ApplicationAssociate ctor not called in same call...

Java Best Practices to Prevent Cross Site Scripting

I have go through the OWASP top ten vulnerabilities and found that Cross-Site Scripting is the one we have to take notes. There was few way recommended solutions. One has stated that Do not use "blacklist" validation to detect XSS in input or to encode output. Searching for and replacing just a few characters ("<" ">" and other similar c...

When should I use Iterable vs. Collection in Java?

What are the considerations of using Iterable<T> vs. Collection<T> in Java? For example, consider implementing a type that is primarily concerned with containing a collection of Foos, and some associated metadata. The constructor of this type allows one-time initialisation of the object list. (The metadata can be set later.) What type s...