java

Looking for an ActiveX equivalent for Java and/or Linux

Hi all, I have a Java application that needs to be able to open multiple different file formats and embed the document within my java JPanel. In Windows I can do this with jaco zoom & ActiveX but I will be working in Linux. I have briefly researched npapi, mozswing, java plug-in technology, and bonobo & kparts. I am hoping to hear fro...

@interface default declaration usage in Java

I have just discovered this feature. Declaring an interface using the "@interface" syntax allows you to put a default value. public @interface HelloWorld { public String sayHello() default "hello world"; } This is something new for me. How is that default value suppose to be used. I cannot find references to that, because the...

Is using a Java Datasource an expensive ordeal?

My Java (non-Web) application may have to create Connection Pools of about 200 different Datasources. Yes, all 200 of them connecting to different Databases. Not 200 connections in the pool. Here are some questions that are bugging me.. 1) Should I anticipate major (performance etc. issues? 2) Are there any Non-commercial Java tools ...

How could I call Java code dynamically ?

How could I write Java code that is executed like javascript code used together with the eval function? What I would like to achieve would be something like this: System.execute ("String str = \"test\"; System.out.println(str);"); which would print the word 'test'. (10x dehmann ) A code sample would help a lot. ...

How do I verify a method call and ignore the return value in EasyMock?

I'm getting frustrated trying to do a simple thing - I want to invoke a method on a mock object and NOT check its return value. I just want to check that it was invoked with the correct parameters. Example: MyInterface mockObject = createMock(MyInterface.class); SomeObject param = new SomeObject(); /* the write object is not void and ...

Removing a custom object from a Java Vector.

I have MyClass, which stores two integers, and I have a Vector<MyClass> called myVector. Now, I do this: ... myVector.add(new MyClass(1,1)); for(MyClass m : myVector) System.out.println(m); System.out.println(myVector.size()); myVector.remove(new MyClass(1,1)); for(MyClass m : myVector) System.out.println(m); System.out.printl...

Does close ever throw an IOException?

After providing some answers here, and reading some comments, it would seem that, in practice IOException is never thrown on close for file I/O. Are there any cases in which calling close on a Stream/Reader/Writer actually throws an IOException? If an exception is actually thrown, how should it be dealt with? ...

How do you deal with generated code?

What is a good strategy for dealing with generated code? One of our projects uses Apache CXF's wsdl2java tool to generate JAX-WS stubs for a set of wsdls. How should this code be dealt with? There are two options that I can see: Generate the stubs once and store them in version control. With this, you don't have to deal with IDE cl...

Overloading a method of a superclass

I am building an AI for an RTS game. (For the Spring RTS engine, if anyone is interested.) The way I have set it up it consists mainly of a collection of Components that communicate by means of fired Events. Every component has a method handleEvent(Event) that receives events fired by the other components. Event is an interface. A hiera...

Quickest method to package a Java console app

I've got a very small set of classes built up in a custom package hierarchy with one console app class that employs them. Everything works fine from JCreator and from a command prompt. I'd like to build a second console app that re-uses that same package. As a Java newbie, what is the quickest, dirtiest method to do that? My main con...

How can I determine which menu item called an ActionListener?

I have a Java program where I have a JMenu with an arbitrary number of items (in this case, there is one menu item for each dynamic library currently loaded in a different program). I'm running a loop to add JCheckBoxMenuItem s to the menu, since I don't know how many there will be. How can I set up an action listener for these menu ite...

Is there an unhandled exception handler in Java?

If i remember correctly in .NET one can register "global" handlers for unhandled exceptions. I am wondering if there is something similar for Java. ...

Android InputStream Internet Disconnect

Hello, In my Android program, I have some code that downloads a file. This works fine, but since on a cell phone, you can be disconnected at any time, I need to change it do it reconnects and resumes the download when you are halfway through and somebody calls/you lose cell reception/etc. I cannot figure out how to detect the InputStream...

Problems with XML/DOM tree rewriting using JDOM (ConcurrentModificationException)

I need to walk a JDOM tree and make changes as I go along; at this point, changes are mostly adding new elements right now but could also include reordering elements or removing elements. All work is done on the same thread so there are no concurrency issues. This turns out to be difficult because JDOM iterators can throw a ConcurrentM...

What is the best way for Adobe flex to communicate with Java?

I am currently working on a project for school which will be a webapp where the gui will be programmed in Adobe Flex and the backend will be programmed in java, probably as servlets running in Tomcat... I am working primarily on the backend things, with another guy in my group heading up the Flex stuff. He is convinced that to communic...

After checking out Subversion code into Eclipse, how do I get it to build?

This problem has been frustrating me for some time... A lot of sites like Sourceforge use SVN or Subversion to manage their code. I have little problem compiling SVN code in C++, but when it comes to Java, my IDE gives me a headache. I've installed Subclipse for SVN support for Eclipse, and it works. I can check out any code into my Wo...

passing test.includes into intellij idea test runner parameters

for example, in ant i would use something like fileset dir="src/tests" includes="${test.includes}" excludes="${test.excludes}"/> in the junit task. there is a Test Runner Parameters field in the Run Configurations in Intellij, but i cant seem to find how to pass that sort of information in. basic use case: i have abstract tests which...

Does Java 64bit perform better than the 32bit version?

I noticed sun is providing a 64bit version of Java. Does it perform better than the 32bit version? ...

Gameloop for j2me "turn-based" game

Edit: This makes alot more sense to me now that i've taken a step away from the code, thanks for the help. Just found stack overflow the other day through Coding Horror and it looks awesome. Figure that i'd ask the community about a problem i'm currently trying to work out. I'm developing a roguelike sortof game using j2me for midp 2....

What does this mysterious Color Method do? What does it return?

Maybe I've had too much coffee, maybe I've been working too long, regardless, I'm at a loss as to what this method does, or rather, why and how it does it, could anyone shed some light upon me? What is the nextColor? public Color nextColor() { int max = 0, min = 1000000000, cr = 0, cg = 0, cb = 0; for (int r = 0; r < 256; r += 4) ...