java

I am having a problem with pointers in java. How do I fix a java.lang.NullPointerException ?

This is a method that gets a element from a Sparse Matrix in java. I keep getting a java.lang.NullPointerException error. I have looked over the code and can't find the error. public int getElement(int row,int col){ int result = 0; MatrixEntry matrixentry = null; if ((row >= 0) && (row < getNumRows()) && (col >= 0) ...

Java permutations with least random numbers possible

hi folks! i looking to generate a permutation of the array a and I dont want to use util function such as shuffle on collections... The permutations(#) should be randomised and every single permutation should be possible - but there is no need for an equally distributed probability. the following code was the first idea that struck my mi...

java serializable interface

In Java some of the objects are serializeable and some or not.An object of a class which implements Serializable interface can be act as serializable object.Also Serializable interface is used for namesake only and there is no methods there.Here my question is ,Java specification can simply say all objects are serializable .user needn't ...

How to adjust speaker volume from Java program ?

I'm running Win Vista, at the lower right side of the window there is a speaker icon next to the clock, I can click on it and adjust the volume, I wonder if there is a way in my Java program to do this automatically. For instance when my Java program starts, it turns the volume to 80, and when the program exits, it changes the volume bac...

How do I sort enum members alphabetically in Java?

I have an enum class like the following: public enum Letter { OMEGA_LETTER("Omega"), GAMMA_LETTER("Gamma"), BETA_LETTER("Beta"), ALPHA_LETTER("Alpha"), private final String description; Letter() { description = toString(); } Letter(String description) { this.description = description; ...

Alternative to Java

I need an alternative to Java, because I am working on a genetics-calculation project. It takes a lot of memory and the most of the cpu time. And therefore it won´t work when I deploy it on a server, because many people use the program at the same time. Does anybody know another language that is not running in a virtual machine and is s...

Running a fastest-algorithm competition

I'd like to run competitions like code golf competitions, but the winner would have the fastest algorithm, not the smallest code. One fair way to measure speed of an algorithm is to use a neutral virtual machine, like Java's JVM. Is there an easy way to know the total number of JVM instructions executed? (If the entry uses multiple t...

weblogic 10.3: EJB JAR is getting deployed as "Library" and not "EJB"

In Weblogic 10.3, the JAR containing the EJB below along with the persistence file, is deployed. But Weblogic deploys it as Type "Library" instead of an "EJB", which is not what I want. package com.sajee; import javax.persistence.*; @Entity @Table(name="REGISTRAR") public class Registrar implements java.io.Serializable { privat...

ClickListener for Composite Widget

Hi, I have a composite widget made of a textbox and a custom widget, which are then added to a verticalPanel. I created this custom widget using Raphael JS. Now i want this Composite widget to recognize both click event and also the ctrl event. I tried implementing clicklistener in both the classes with no fruitful results. here is t...

pattern matching and range checking with regex in java

My application will basically accept user input via the main(String[] args) method. I have been trying to figure a way to do some checking with that input using a patter matcher. Each valid input consists basically of a single character: (blanks should be ignored) * 'R' or 'r' - replay * 'Q' or 'q' - quit * [1-6] - perform tasks 1 .. 6...

Copy java object/class from one classloader to another classloader

Hi is there a way to copy one class loaded context (atrributes etc) from one classloader (for instance a 'made' class Point) to another classloader? Making clear, Example: I have an object Point on CL 1. Now running on another CL2, I want to creat this object in CL 3. Some obj: class Point { int x; int y; public Point() {} //getters...

App-engine and Scala

Hello, all. I have a 2-part question: Could you use Scala with Google's App Engine instead of Java? (Assuming 1 is answered yes) Would it be advised? Thanks ...

Which is better to continue Java EE or Spring Framework?

I am not so much experienced on enterprise systems but i have some experience on Spring framework.I start to think open source framework such as Spring,Hibernate start to become defacto in enterprise development.Do you think it is necessary to learn Java EE 6 to become experienced on enterprise development cause i do not have so much exp...

referencing java objects on a sorted map by index?

I have a sorted map and want to reference its ordered objects by their index position. Is this possible? How would I convert a sorted map to an array list while maintaining the ordering, so I can retrieve an object by its index (order). Is this the only way to do it? Ideally I could have this structure, and would know the index of an ob...

How do I split an integer into 2 byte binary?

Given private int width = 400; private byte [] data = new byte [2]; I want to split the integer "width" into two bytes and load data[0] with the high byte and data[1] with the low byte. That is binary value of 400 = 1 1001 0000 so data[0] should contain 0000 0001 and data[1] should contain 1001 0000 ...

Merge Sort Java

Hi. I am trying to make a merge sort method, but it keeps on giving the wrong sorts. Where do I have change to make it actually sort the array? What part of the code has to be different? Thank you for your time. public static void mergeSort(int[] array, int left, int lHigh, int right, int rHigh) { int elements = (rHigh - l...

Simple statistics - Java packages for calculating mean, standard deviation, etc...

Could you please suggest any simple Java statistics packages? I don't necessarily need any of the advanced stuff. I was quite surprised that there does not appear to be a function to calculate the Mean in the java.lang.Math package... What are you guys using for this? EDIT Regarding: How hard is it to write a simple class tha...

one-to-many JPA annotations won't delete orphans

Hello good people. I 'm trying to build a user and a contact management project. i have a lot of classes so will limit it to what are in concern here. i have a userAccount, userProfile, and group here is the UserAccount Mapping @Id @GeneratedValue @Column(name="USER_ACCOUNT_ID") private Long ID; ...... @Column(name="EMAIL", length=10...

Java portable media detection

I would like to write a piece of java code that synchronizes files between local hard drive and a usb storage. I would like to have a different synchronization configuration depending on which usb storage is plugged in and I would like to have apropriate configuration to be selected automatically rather than chosen by the user. I've jus...

Resources for programming a system that supports plugins

I need resources -preferably a text- about programming systems that supports plugins or extensibility and other related detailed stuff, like handling permissions and resources for those plugins ...