java

Twisted in Java

What is the closest Java alternative to Twisted? ...

C++ Parser/Model for Java

I was wondering if anyone knows of existing C++ parsers/code models that can be used programmatically in Java. I'm looking for something similar to the Eclipse CDT that can be used as a library from Java (and that does not rely upon Eclipse). Thanks in advance. ...

Can EventActionDispatcher publish "this" before the constructor finishes?

The recommended way to use the EventActionDispatcher is as follows (per the API docs @ http://struts.apache.org/1.2.9/api/org/apache/struts/actions/EventActionDispatcher.html ) public class MyCustomAction extends Action { protected ActionDispatcher dispatcher = new EventActionDispatcher(this); public ActionForward exe...

Scala collection standard practice

Coming from a Java background, I'm used to the common practice of dealing with collections: obviously there would be exceptions but usually code would look like: public class MyClass { private Set<String> mySet; public void init() { Set<String> s = new LinkedHashSet<String>(); s.add("Hello"); s.add("World"); mySet ...

How do I parameterize an extended Collection.

I've been trying to extend the ArrayList class without much success. I want to extend it, and be able to parameterize it. So normally you have something like ArrayList<SomeObject> list = new ArrayList<SomeObject>(); I want MyList<SomeObject> list = new MyList<SomeObject>(); Simply extending ArrayList doesn't work. public class M...

Can anyone help with a java problem regarding date properties?

I basically want to say if the date is unchanged run this alert my date field is set up like this StartDate = new DateField("Start Date ", DateField.DATE); cal1 = Calendar.getInstance(); cal1.set(Calendar.YEAR, 2009); cal1.set(Calendar.MONTH, 3); cal1.set...

JVM sending back memory to OS

Hi all, I have a question regarding the JVM memory management (at least for the SUN's one). I would like to know how to control the fact that the JVM send the unused memory back to the OS (windows in my case). I wrote a simple java program to illustrate what I expect. Run it with -Dcom.sun.management.jmxremote option so that you can a...

How to get java 1.6 applet working on mac os x

anyone got java 1.6 applet working on mac os x ? check it on gemal.dk/browserspy/java.html I got Java using object and applet tag 1.5.0_16 (1.5.0_16-133) from Apple Inc. and you ? on windows and linux 1.6 working gracefully :S ...

Trouble Updating Title in JInternalFrame GUI component.

Hello, i am trying to update the title of a JInternalFrame component in my Java Project. The component is an instance of my ImageFrame class which extends JInternalFrame, and in my code I call a setter method in my ImageFrame class which updates the title attribute. I ran a Unit test and know that the attribute is updating properly, bu...

java.lang.NoClassDefFoundError: happens sporadically on Resin sever start up

java.lang.NoClassDefFoundError: happens sporadically on Resin sever start up This is on Resin 3.0.21 Using Java 1.5 on Linux machine... I have a servlet defined on the web.xml to load the log4j.properties. This is thrown when the servlet is trying to load on start up.. log4j-init: init log4j:ERROR Could not instantiate class [org.apa...

Finding your application's URL with only a ServletContext

I'm writing a Java web app using Spring MVC. I have a background process that goes through the database and finds notifications that must be e-mailed to my users. These e-mail messages need to include hyperlinks to the application. This seems like a fairly common pattern for a web app, but I'm having trouble. How do I derive my applicat...

Where are Java preferences stored on Mac OS X?

On Windows, the Java preferences, which you access in your application from java.util.prefs.Preferences are stored in the registry. Where are those stored on Mac OS X? ...

How to fill color on triangle

Hi everyone, I draw a triangle using line. How can I fill color on it? So far I can only success color the line but not fill the color. public void paintComponent(Graphics g){ super.paintComponents(g); int k=0; for (j=0 ; j < numOfLines; j++){ // the values of numOfLines retrieved from other method. g....

What's the right way in Java to connect to a Microsoft Access 2007 database?

I'm trying to create a simple connection using the jdbc-odbc bridge: public static Connection getConnection() { Connection con =null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String conStr = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + "c:\\myfolder\\accesdbfile.ac...

How do I inject dependencies into resources with Jersey?

My initial look at Jersey suggested this was a nice framework that made it easy to create RESTful Java APIs. Unfortunately, since making the decision to use it (together with Grizzly), I've found it to be very poorly documented, consequently it is very hard to perform common tasks (that I'm sure are very easy once you know how). Anyway...

Java resource as file

Is there a way in Java to construct a File instance on a resource retrieved from a jar through the classloader? My application uses some files from the jar (default) or from a filesystem directory specified at runtime (user input). I'm looking for a consistent way of a) loading these files as a stream b) listing the files in the user-de...

How to send array files to other class

How can i send a files which stored in array to other class? I have tried this code but isnt working. public class abc { .... String [] indexFiles = new String[100]; public abc (){ indexFiles [0]=image1.txt; indexFiles [1]=image1.txt; .... draw = new drawing (indexFiles(0)); // I got error in th...

Do you follow any guidelines (java) in packaging?

Do you follow any design guidelines in java packaging? is proper packaging is part of the design skill? are there any document about it? Edit : How packages has to depend on each other?, is cyclic packages unavoidable?, not about jar or war files. ...

Changing JAAS roles based on software license flags

I've got a pretty ordinary JEE application running on JBOSS. It uses the JBoss DatabaseLoginModule JAAS authentication. It also has application layer users/roles in Hibernate that are exactly the same. I've got an idea ( which I think is pretty useful for me, anyway) to have a capability bit I can set in the software license object (not...

Different ways of loading a file as an InputStream

What's the difference between InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName) and InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName) and InputStream is = this.getClass().getResourceAsStream(fileName) When are each one more appropriate to use tha...