java

java expression language that can't access 'unsafe' java methods

I am working on a project where I will let users submit small 'scripts' to the server, and I will execute those scripts. There are many scripting languages which can be embedded into a Java program, such as mvel, ognl, uel, clojure, rhino javascript, etc., but, as far as I can tell, they all allow script writer to call Java constructors...

Dictionary class

is it possible to have multiple values for a single key in the java dictionary class?? ...

Switch Statement for Enum Value Representations in Java

I'm very familiar with using Enums in other languages, but I'm having some difficulty in Java with a particular use. The Sun documentation for Enums boldly states: "Java programming language enums are far more powerful than their counterparts in other languages, which are little more than glorified integers." Well, that's dandy, ...

What is wrong with this clone()?

I have written this clone method for when the parent of the Employee class is abstract and the clone() method in the parent class is abstract.I wanted to copy the primitive data type of the Employee's object with this code instead of copying each primitive data type individually, but this code has problem with the line that I call clone(...

Moving from Java to Python

Hi, I've got a junior starting who's coming from a Java background. As a company we're now focused on Python development(albeit with some legacy systems in Java hanging around). I'm looking around for tips and resources to help the transition and wondered if you guys here had any useful tips for a newbie. Cheers. ...

scrollbars in JTextArea

How do I add scrollbars to a JTextArea? ...

Wrap exceptions by runtime exceptions with an annotation

Is there a way to annotate a method so all exceptions thrown are converted to runtime exception automagically? @MagicAnnotation // no throws clause! void foo() { throw new Exception("bar")' } ...

Why must jUnit's fixtureSetup be static?

I marked a method with jUnit's @BeforeClass annotation, and got this exception saying it must be static. What's the rationale? This forces all my init to be on static fields, for no good reason as far as I see. In .Net (NUnit), this is not the case. Edit - the fact that a method annotated with @BeforeClass runs only once has nothing to...

Spring MVC form input value is always null

Hi all, I'm new to Spring MVC, but not new to web development in Java. I'm attempting to create a simple form->controller example. I have a form, a form controller (configured in a context XML pasted below) and my model (a simple bean). When I submit the form the value of my text input is always null, regardless. Any ideas? Form cont...

java.io.IOException: Invalid Keystore format

Hello, Does anyone know how to solve this? I tryed many things non of them work :( And when i click more details i get this: at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source) atsun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown Source) at java.security.KeyStore.load(Unknown Source) at com.sun.deploy.security.Root...

Having hard time to publish files to Tomcat from Eclipse

Hello good fellas! Sorry if my question seems dumb. I've started using Eclipse Ganymede 3.4 this week and having hard time publishing my projects to the web app server. First of all you need to know this issue: i installed my Tomcat 6.0.18 from Netbeans that i use for PHP and J2SE project. While i can start that server from either Netb...

Are there (experimental) JSR-262 JMX-WS enabled Java tools or applications?

I am very interested in the Web Services Connector for Java Management Extensions (JMX) Agents and the reference implementation ws-jmx-connector. JSR 262 will provide a new opportunity for cross-platform/cross-language enterprise integration projects, given the option to communicate with JMX Agents using non-Java clients. (I have been ab...

mouse clicks in jfreechart !

Hi, In my JfreeChart application I need to perform some actions when the user clicks the mouse on the chart. For this, I have a inner class that implements the ChartMouseListener and an instance of this class added as a chartMouseListener to the chartPanel. The strange thing , which I cannot comprehend why , is that sometimes when I cli...

Good book for puzzle

I am great fan of book like "Java Puzzler". I want to know about other book titles which provides similar contents like "Java Puzzler" (Mostly for java). Same time looking for good general puzzle book also. Please suggest some titles. ...

Swing: How to achieve forwarding of all events from subcomponents to parent container?

Hello! I'm looking for a straightforward way to make a Swing component forward all received events to its parent container (or even all parents up to root). EDIT: Where do I need this? I have a diagram editor. Components must forward key press and mouse clicks (to set themselves as "active" as soon as the user clicks a subelement of th...

In java, how do I create my own xml subclassed elements in a DOM returned by 3rd party tools.

So I'm using HTMLCleaner which returns a org.w3c.dom compatible DOM. Now, I want to insert my own subclassed Elements (which implement additional functionality outside the dom) into this dom tree. Is this possible? If you use the Document.createElement(), you can't say that you want it to create your implementation of an element. Ideall...

Eclipse - java.lang.ClassNotFoundException

Hi all, I have no idea what's wrong here, so you guys are my last chance: When trying to start my JUnit-Test out of Eclipse, I get a "ClassNotFoundException". When running "mvn test" from console - everything works fine. Also, there are no problems reported in Eclipse. My project structure is the following: parent project (pom-packa...

Making a lottery program in Java

I was wondering, what do i need to look at to get cracking with making a programme that can read from a excel file I was thinking of making a programme that uses a excel spreadsheet and reading them in and generating a list of combinations that have not occured yet Its just for a bit of fun, but could be a good challenege thanks ...

Need help with a Java Problem.

I am trying to solve the following problem: Problem: Write a program that displays the integers between 1 and 100 that are divisible by either 6 or 7 but not both. Here is my code: import acm.program.*; public class Problem4 extends ConsoleProgram { public void run() { for (int i = 1; i <= 100; i++) {...

I need to save a String to a text file using Java

I am a beginner Java programmer. I am attempting to make a simple text editor. I have got the text from the text field into a variable that's a String, called "text". My question is, how can I save the contents of the "text" variable to a text file? Thank you! ...