java

Eclipse Failing to build classes

Hi, Eclipse has red cross for error on the project but there are no more red crosses on any files or anything in the project. On running "build Project" there are no .class files created. There does not seem to be any entries in the log file in workspace/.metadata. In fact, I deleted the log file and a new one has not been created. ...

Function composition in Java

I'm trying to implement a lazy sequence (meaning that the next item is only calculated when you invoke the step function), and one of the methods it should have is "map" which receives a function that affects all the members. The most elegant way to do this is to use function composition, and assign the new function to the function varia...

Migrating from Tomcat 5.5.x to 6.0.x.

I'm migrating an mature application from Tomcat 5.5.x to 6.0.x. What are the sticking points that I need to make sure that I address? I use a couple of Tomcat's services that I suspect will need adjustment... The logging mechanism: I altered the conf/logging.properties to include my webapp. The Resource of type="javax.sql.DataSource...

Java: upcasting Collection<T> to Collection<U super T>

I have a Collection<T>. I have a class TManager implementing an interface UManager which has a method getCollection() that needs to return a Collection<U> where U is an interface, and T is a class that implements U. Aside from just casting it, e.g. return (Collection<U>)Tcoll;, is there a more correct way to handle this? I control all ...

When NOT to use the static keyword in Java?

When is it considered poor practice to use the static keyword in Java on method signatures? If a method performs a function based upon some arguments, and does not require access to fields that are not static, then wouldn't you always want these types of methods to be static? ...

Object decomposition depth in Java

I'm wondering about the following issue: How deep should one go when designing an application in decomposing the working entities into objects? What I mean could be described better by the following example. Lets consider that I'm designing an application that is used to manage books. For that the basic model would be the book. So at ...

TeamCity + git-teamcity plugin: ParseException

Alright, I've trying to set up a TeamCity server the past few hours, but this as really gotten me stuck. I've got everything working, agents are running, plugin is installed, but when I run the build process it instantly crashes with the following log error: Error collecting changes for VCS root '[email protected]:chrisjowen/nLess.git:mast...

Beginner object references question

If I instantiate an object in a main class, say: SomeObject aRef = new SomeObject(); Then I instantiate another object from the main class, say: AnotherObject xRef = new AnotherObject(); How can the instance of AnotherObject make use of the aRef reference to access the methods in SomeObject? (To use the same instance of SomeObject)...

Java Beans - creating an inspector window

I'm wondering whether there is an existing Java class that, given a Java bean, uses introspection to find all the publicly modifiable fields, and displays them using default PropertyEditors. I see a bunch of information about BeanInfo, PropertyEditor, Bean Customizers, but nowhere can I find actual examples. Basically I want the functi...

Mozilla Rhino: Different ways of adding Java object to scope

I've got this piece of Java code with embedded Rhino (irrelevant bits omitted): Context cx = Context.enter(); Scriptable scope = cx.initStandardObjects(); scope.put("foo", scope, Context.toObject(foo, scope)); ScriptableObject.putProperty(scope, "bar", Context.javaToJS(bar, scope)); where foo extends ScriptableObject and bar is just...

How to Initialize Server only Once in PHP

I am porting an application from Java Servlet to PHP. What's the equivalent of Servlet.init() in PHP? Basically, the page uses a table that needs to be calculated. It's quite expensive operations. I am using a LAMP. I wonder if there is a way to initialize the table just once at Apache startup? ...

How do I retrieve the attribute of an element using Swing's HTMLEditorKit.ParserCallback?

I am extending HTMLEditorKit.ParserCallback to parse HTML. I am matching on a certain element type in an overridden method like this: @Override public void handleStartTag(Tag t, MutableAttributeSet a, int pos) { if (Tag.DIV.equals(t)) { String id = (String) a.getAttribute("id"); String clazz = (String) a.getAttribute...

Java HotSpot error

Curious if anyone could help out in regards to a Java HotSpot dump...saw some reference to head over to the Sun Forums, figured I would try here first...below is the dump... # # An unexpected error has been detected by Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d8c8f23, pid=2836, tid=5980 # # Java VM...

Using Java to retrieve the CPU Usage for Window's Processes

Hello all, I am looking for a Java solution to finding the CPU usage for a running process in Windows. After looking around the web, there seems to be little information on a solution in Java. Keep in mind, I am not looking to find the CPU usage for the JVM, but any process running in Windows at the time. I am able to retrieve the memo...

Binary Tree Nodes - Which Way?

For an assignment we were given in Data Structures, we had to create a test class to determine whether the code we were given correctly traversed the binary trees in our test class. These are the 3 constructors for BinaryTreeNode class that was given to us: public BinaryTreeNode(Object theElement, BinaryTreeNode theleftChild, BinaryTre...

Programatically access Google App Engine Quota Details

Does anyone know if it is possible to access via code either from within App Engine SDK or some form of WebAPI your current account quota details. I would like to be able to track the datastore usage and bandwidth usage within the running application so that it may alter its behaviour depending on the levels of Quota left for the applic...

Under what circumstances does Groovy use AbstractConcurrentMap?

(Specifically, org.codehaus.groovy.util.AbstractConcurrentMap) While doing some profiling of our application thats mixed Java/Groovy, I'm seeing a lot of references to the AbstractConcurrentMap class, none of which are explicit in the code base. Does groovy use this class when maps are instantiated in the groovy dynamic def myMap = [:]...

java singleton pattern, should all variables be class variables?

If a class implements a singleton pattern, should all the variables be declared static? Is there any reason they shouldn't be declared static? Does it make a difference? ...

java wrapper around log4j logger and java.util.logging

I am writing a library. The library can be used by applications that use log4j loggers and java.util.logging loggers. So, I wrote a quick wrapper class, that encapsulates both loggers. I allow the application to set one or both loggers. And in my library I use the encapsulated class to print to either logger. My question is, since many...

How can I customize Java Date Format

Hi, From the java doc, the MEDIUM format is: MEDIUM is longer, such as Jan 12, 1952 http://java.sun.com/j2se/1.4.2/docs/api/java/text/DateFormat.html How can I customize it so that I does not display the year? And spell out "Jan" to January? Do I need to do that myself? * chop off the string after the ',' * have a table which map th...