java

What optimisations can I expect java.util.regex to perform?

Does Java perform any regex optimisations; if so, what are they? I'm interested in both optimisations at the regex engine level, and more general usage-level optimisations. (For example, in some other languages, commonly used regexes are cached to avoid re-compiling, but what I've read so far implies that Java doesn't do this automatic...

Where is the jar files cached for Java Web Start/JNLP applications?

Where is the jar files cached for Java Web Start/JNLP applications? ...

moving a row in jTable

how can one move a row in jTable so that row1 goes to row2's position and row2 goes to row1's position ? ...

Why use the ServletContext object in a web-app containing servlets and "worker" threads in Java

Hi, I currently have a web-app where I have Servlets reading and writing to the ServletContext attributes and I have "working" Threads (Daemon threads) which get initialized on startup and currently hold as a member the ServletContext object. For a couple of reasons I'm thinking of moving to "implement Runnable" instead and I'm kind of s...

How do you use Jython for your Java development?

So you aren't allowed to use Jython for the production code you develop at work. You can, instead, use it to help you on your daily tasks and activities writing that Java code. The question is: How do you use Jython and how did that help your development and/or productivity? ...

Java: How do you access a sub-object of an object with no "getXXX" method to that sub-object

I'll explain with pictures from Eclipse Debugger I have an Class called "FieldContext", (I can't edit it, it's compiled in the Java OVal API) Within "FieldContext" on the eclipse variable tab are "CompileTimeType" and "field" Q1 Is there a legend for the icons in the variables tab? like what the red box with the "F" means + yellow d...

Eclipse 3.5.1 Compiler Error :The type OutputFormat is not accessible due to restriction on required library ../rt.jar

This error is weird and i cannot make much sense of it. I've installed EclipseRCP 3.5.1, Java SE 1.6 update 16 and switched to SWT 3.5. I've created a new project, set up the dependencies and tried to compile. When trying to import, use the following: import com.sun.org.apache.xml.internal.serialize.OutputFormat; import com.sun.org.apac...

java -- compiling with a .Jar file -- help?

Hey, I'm trying to compile my class along with a provided .jar file which contains classes that my class will use. This is what I've been trying: javac -classpath .:WordSearch.jar WordSearchSolver.java And this is the response: WordSearchSolver.java:16: cannot find symbol symbol : class PuzzleWord location: class WordSearchSolver ...

Variable scope in the code

I was going over the tutorials for GWT and was confused by this piece of code. The code is at GWT tutorials private void addStock() { final String symbol = newSymbolTextBox.getText().toUpperCase().trim(); newSymbolTextBox.setFocus(true); // Stock code must be between 1 and 10 chars that are numbers, letters, ...

Sorting on Last Name ...

I am reading data from three files and then i want to sort the records on some criteria Each file has records in the following format First Name Last Name Gender Color Date This is the code which i have ... i can sort only on the first name using collections.sort ... how do i sort on other columns ... any help would be appreciated ...

What best book on data structures in java is recommended ?

Hi, I am looking for Best book on data-structures in Java, I know there are few good books on Data structures but they are from C++ perspective and am looking from Java perspective. Thanks. ...

how to know which constructor was used in creating an object?

Consider Class A has two constructors new A(int), new A(int, String) also it has a method show() Then given a statement like, A a1= new A(4); A a2= new A(3, "foo"); and later in code (or in some methods where these object were passed) a1.show(); a2.show(); new A(3).show(); and new A(2,"bar").show(); If I wanted to differen...

Performance of Java 1.6 vs C++ ?

Hi, With Java 1.6 out can we say that performance of Java 1.6 is almost equivalent to C++ code or still there is lot to improve on performance front in Java compared to C++ ? Thanks. ...

Why would you use logging.properties if App Engine automatically logs stdout & stderr to INFO & WARNING?

According to the documentation for Google App Engine for Java: The App Engine Java SDK includes a template logging.properties file, in the appengine-java-sdk/config/user/ directory. To use it, copy the file to your WEB-INF/classes directory (or elsewhere in the WAR), then the system property java.util.logging.config.file ...

Creating a reference in Java

I want to use a reference as a shorthand to an array element, where the array consists of elements of a basic type (integers). How can I explicitly create a reference in Java? Is it possible? /* ... */ //neighbors = new int[][] //I'm using neighbor, below, to refer to an element in neighbors so that the code //is easier to read. I want ...

Why would you want to set system properties such as java.vm.specification.version on App Engine?

According to the App Engine documentation, you can set system properties and environment variables for your app in the deployment descriptor and App Engine sets the following system properties when it initializes the JVM on an app server: * file.separator * path.separator * line.separator * java.version * java.vendor * java.vendor.url *...

What is the best datastructure to use in Java for a "multidimensional" list?

I need a dictionary-like data structure that stores information as follows: key [value 1] [value 2] ... I need to be able to look up a given value by supplying the key and the value I desire (the number of values is constant). A hash table is the first thing that came to my mind but I don't think it can be used for multiple values. ...

HashMap vs ArrayList performance am I correct

I currently believe that: When you need a structure from which you will be retrieving items randomly - use a HashMap When you will be retrieving items in order (e.g. using a for loop) - use an ArrayList Am I generally correct? Are there situations where this is not correct? ...

What is the objective of setting the minimum heap size in an android app ?

In google's Calendar app for Android OS, you will encounter this line in the onCreate method of CalendarActivity. // Eliminate extra GCs during startup by setting the initial heap size to 4MB. VMRuntime.getRuntime().setMinimumHeapSize(INITIAL_HEAP_SIZE) Can someone explain why setting it to 4MB will eliminate GCs ? Thanks ...

Read Java JVM startup parameters (eg -Xmx)

I'm trying to figure out if there's a way to determine the JVM startup properties from within a running java process. Specifically I'm trying to find out where parameters such as -Xmx (max heap size) and -XX:MaxPermSize are stored. I'm running Sun's 1.6 jvm. If you're wondering why I want to do this, I have a number of JVM webservers ...