java

Writing to modbus with Jamod

Hi I came across with a curious situation when using jamod to write to modbus. Following read code works perfectly: public static void main(String[] args) throws Exception { InetAddress address = InetAddress.getByName("host.somewhere"); TCPMasterConnection connection = new TCPMasterConnection(address); connection.setPort(502);...

java need storing values in a multi-dimension array. what is the best method to reserve memory space?

Hi at first sorry for my poor grammar. I want to build a simple hierarchical clustering algorithm in Java, so i need to build a similarity matrix, whose ij entry gives the similarity between i and j clusters. The first thought is using int[][] for storing this matrix (each cluster has an ID of type integer). I think that having for ...

Eclipse (Galileo) : Why does "Initializing Java Tooling : 59%" take FOREVER?

Hello all, New to Java and Eclipse. For some reason, the first time I load Eclipse on a given day, it freezes at "Initializing Java Tooling : 59%". Eventually, it gets past this and I can do my work. However, this "Initializing Java Tooling : 59%" stage takes a REALLY REALLY REALLY long time. Does anybody know why it does this or ho...

Java Jnlp CodeSigner Error

I am trying to run a java jnlp application from my computer. Every time I try launch the file I get the error java.lang.NoClassDefFoundError: java/security/CodeSigner From searching Google it seems to be a common enough problem and is normally blamed on 'java 6'. I couldn't find a solution that doesn't involve rolling back to an older j...

unsigned short in java

Hi how can i declare an unsigned short value in Java? Thank you ...

Change in GC behaviour after move from Java5 to 6

We've recently migrated our systems from Sun Java 5 to Java6 server VM (specifically, 1.6.0_16 on Linux 32 bit). We've noticed that the garbage collection behaviour has changed in such a way as to trigger our heap-warning monitoring system. The heap usage graphs indicate a much "spikier" memory usage profile than we saw with Java5, wit...

text in text box

hi, i am pretty new to the gwt framework and i am using it for building the ui of my web site, i would like to make the text box have a text in it that once the user clicks on it for the first time, the text disappears. and in the rest of the time it behaves like a normal text box any ideas on how to do it? ...

AffineTransformOp speed/memory question

I have asked this question before, but I wanted to rephrase/clarify some points and expand upon it. I have a piece of code which transforms a BufferedImage using an AffineTransform. op = new AffineTransformOp(atx, interactive ? interpolationInteractive : interpolationNormal); displayImage = op.filter(displayImage, null); This code wo...

How handles JPA JOINs with available foreign key entry but not available foreign entry?

I wonder how JPA defines to handle following scenario: Table A: | Table B: ID FK_B | ID 1 10 | 10 2 null | 12 3 11 | I want all Table A entries with FK_B NULL or referencing not available Table B entry. public class A implements Serializable { @Id private Long id; @JoinColumn(name = "FK_B", nullable = true) ...

Using HTML builders in grails instead of GSP

Hello, is there a way to use groovy builders to build JSP files in a Grails application keeping things enough integrated? To explain better: by default Grails uses gsp files that are nice but quite verbose.. <div class="clear"> <ul id="nav"> <li><g:link controller="snippets" action="list">Snippets</g:link></li> <li><g:link ...

In JVM heap can there be more than one object with the same hash code?

This is a an interview question. ...

Can I compile a java file with a different name than the class?

Is there any way to compile a java program without having the java file name with its base class name. If so, please explain.. ...

Can I use an Environment variable based location for Spring FileSystemResource?

I have a requirement to have all our properties files be stored in a directory. The location of this directory should be stored in a system environment variable. In my application context I will need to access this environment variable to create the FileSystemResource bean. Here is an example of what I would normally have: <bean id="pr...

Basic Java threading issue

Lets say I'm interacting with a system that has two incrementing counters which depend on each other (these counters will never decrement): int totalFoos; // barredFoos plus nonBarredFoos int barredFoos; I also have two methods: int getTotalFoos(); // Basically a network call to localhost int getBarredFoos(); // Basically a network call...

Is there a "fastest way" to construct Strings in Java?

I normally create a String in Java the following way: String foo = "123456"; However, My lecturer has insisted to me that forming a String using the format method, as so: String foo = String.format("%s", 123456); Is much faster. Also, he says that using the StringBuilder class is even faster. StringBuilder sb = new StringBuilde...

Fitnesse Framework regular expressions possible?

Hi all, Is there an easy way in Fitnesse to check cells based on regex patterns? This should work for all the possible fixtures like "query table", "decision table" and so on. E.g. if results(rows) are returned from a query table it should be possible to match certain cells (columns) against a regex, not just a fixed string. I guess you...

How to enter info from notebook touch pad with Java

I wonder if there is any sample Java program that shows how to get info from notebook touch pads, for instance if I want to develop a Java app that can get users' handwriting from the touch pad. It's like drawing with a mouse into a canvas, except I want to use my finger to enter info. ...

Java: Linebreaks in JLabels?

I'm trying to make a Swing JLabel with multiple lines of text. It's added just fine, but the line breaks don't come through. How do I do this? Alternatively, can I just specify a maximum width for a JLabel and know that the text would wrap, like in a div? private void addLegend() { JPanel comparisonPanel = getComparisonPanel();...

writing large excel spreadsheets

has anybody found a library that works well with large spreadsheets? I've tried apache's POI but it fails miserably working with large files - both reading and writing. It uses massive amounts of memory leaving you needing a supercomputer to parse or create a 20+mb spreadsheet. Surely there is a more memory efficient way and someone ha...

Multi-Dimensional Graphing Libraries for Java

I have been working on projects that deal with 2-Dimensional graphing, UML diagramming and relational graphing (node-link diagrams). I am interested in moving to projects that deal more with 3-Dimensional graphing of scatter plots and 3-Dimensional navigation. Could someone suggest a few books, or libraries that would help me get started...