java

Loading and analyzing massive amounts of data

So for some research work, I need to analyze a ton of raw movement data (currently almost a gig of data, and growing) and spit out quantitative information and plots. I wrote most of it using Groovy (with JFreeChart for charting) and when performance became an issue, I rewrote the core parts in Java. The problem is that analysis and pl...

Developing Java, C#, and .NET on the same machine

I found a couple of threads that touch on development of C#/Java apps but I don't think they go along with this question. I was wondering if it was a good idea to be developing Java, C#, and .NET applications on one computer. That means there's ## .NET versions installed at one time, ### Java JRE's installed at any given time. Is that a...

Java: Get first item from a collection

If I have a collection, such as Collection<String> strs, how can I get the first item out? I could just call an Iterator, take its first next(), then throw the Iterator away. Is there a less wasteful way to do it? ...

Java: Generate a Powerset

This could be language agnostic/helpful answers could just be in pseudo-code. I have a program that I would like to test under a range of inputs. This program takes a set of files, one of which is designated as the root. I want to run the program with all possible subsets of files. (Two subsets, containing the same files, but with diffe...

Indirect reference in Freemarker

Using freemarker, is there any way to reference a value indirectly along the lines of... <#assign apple=fruit> <#assign item=apple> ${${item}} to produce the output 'fruit' without prior knowledge of what value item might contain? ...

Java: Nested generics?

Can Java nest generics? The following is giving me an error in Eclipse: ArrayList<ArrayList<Integer>> numSetSet = ArrayList<ArrayList<Integer>>(); The error is: Syntax error on token "(", Expression expected after this token ...

How to integrate an external process which is invoked repeatedly into a Java webapp?

I am trying to integrate a non-Java executable into a Java webapp on the server-side (Linux). Some details about the executable: Written in C++. The executable takes some input either from stdin or file and generates an output file. The executable is not designed to be a long running process i.e it generates an output and then dies out...

Java Socket's app randomly stopping

Server public void run () { Socket serversocket = new ServerSocket(port); while(true) { new Thread(new ServerThread(serverSocket.accept())).start(); } } //serverSocket.close(); etc ServerThread public void run() { BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); String input; w...

Java Swing: JInternalFrame: need a dialog popup

I have a JInternalFrame window that needs to popup a modal dialog box when a JButton is pressed. At first, I tried using JDialog, but I found that JDialog constructor needs: JFrame boolean modal I tried passing JInternalFrame to it, but the type didn't match. Should I use JDialog with JInternalFrame? What if I dont specify the owner...

Setting the content-type of a response in Struts2

So, I'm using freemarker templates with Struts2 to formulate my responses. However, since I'm trying to use taconite as well, I need the response to be sent with the content type of "text/xml". I can't seem to find a way to use freemarker directives to set the content type, and I am not well versed enough in struts to know if there is ...

How to extract the server Host/IP from the CORBA IOR & NamingContextExt? [Java]

I've got a Client who needs to send a UDP packet to a server and the only reference he has to the Server is through the CORBA naming service (IOR). I know the IOR has the Server Information embedded but is there an easy way for me to extract it? This is the code I have so far: Object objRef = orb.resolve_initial_references("NameService...

My Spring AOP not working

I need help making AOP work. What am I missing here? <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2...

Java: how come this does not compile?

How come this code doesnt compile? class A { class B { public enum Enum <-- this line { AD, BC } } } Compiler reports: enum declarations allowed only in static contexts. But then when I put the Enum inside class A, everything is okay. This is quite surprising. I dont think I have this problem in C++...

Java Hashtable and serialization

Hi .. I have a problem in Java hashtable serialization that seems illogical to me but i am not able to find out the error in the logic i am using. Here is what i am doing, Hashtable sspsrpData = new Hashtable(); for(int i=0;i<Constants.secondayStructures.length;i++) { SecondaryStructures ss = (SecondaryStructures)(data.get(Constant...

Why is String[] args required in Java?

I understand that String[] args is an array of strings passed into main as parameters. java Print "Hello, World!"   class Print { public static void main(String[] args) { System.out.println(args[0]); } } However, when you don't include it as a parameter (even if you don't use), it throws an exception. So why is it required?...

Reuse Eclipse's Plugin Manifest Editor

I want to have the PluginManifestEditor functionality in my view(not in a editor). Also I need to add some extra pages to it(along with the existing ones like Overview, Dependencies, runtime etc.). I know that its implemented in org.eclipse.pde.ui plugin. I just started diggin in to the code and found that the javadoc is sparse and not ...

Extracting path using Java

How to extract the path "c:/documents and settings/user" using Java... Is there any method?? ...

Is AtomicInteger a good solution to provide a counter for multithreaded app ?

I have an android client which will make Http connections to a server. The server requires that all Http request provide a monotonically increasing counter in the Http header. e.g. POST /foo/server X-count: 43 Places that will initiate Http connections: Inside activities under the user's command e.g. button clicks Inside a Service ...

How KVM (Kilo Virtual Machine) different from JVM(Java Virtual Machine) ?

I have basic idea on Kilo Virtual Machine on Mobiles , I have clear idea of how JVM works class loaders , Executable Engine,Method Area etc . Technically how KVM differs from JVM ? Does KVM increases the execution time as compared to JVM ? Any Performance Oriented difference ? Memory management Thanks ! ...

hibernate many-to-many

Hi, i have three tables and 2 JPA model classes: Unit ------------ id [PK] - Integer code - String unitGroups - List<UnitGroup> UnitGroup ------------ id [PK] - Integer ugKey - String units - List<Unit> units and unitGroups have many-to-many relationship between themselves. briefly i want to write an HQL query...