java

Final variable manipulation in Java

Hi, Could anyone please tell me what is the meaning of the following line in context of Java: final variable can still be manipulated unless it's immutable As far as I know, by declaring any variable as final, you can't change it again, then what they mean with the word immutable in above line? ...

decompiling DEX into Java sourcecode

Are there any tools or recipes for turning Android DEX (VM bytecode) files into corresponding Java sourcecode? ...

Why not SingleThreadModel synchronizing the attributes?

Hi, I'm a little confused by the following paragraph: "The effect of implementing SingleThreadModel is virtually the same as synchronizing the service method. Both can bring a web app to its knees without protecting the session and context state." As STM synchronizes the service method, so isn't it quite obvious that it'll also synchr...

Generic Java pattern recognition library - like regexps for List<Object>

Is there a library that would let me write regexp-like queries for lists of objects, just like java.util.regexp matches against strings, which are conceptually like lists of characters? I want to be able to use patterns with greedy/conservative quantifiers, identifying groups in matches, etc. Obviously I would have to provide the code f...

Manipulate MP3 programmatically: Muting certain parts?

I'm trying to write a batch process that can take an MP3 file and mute certain parts of it, ideally in Python or Java. Take this example: Given a 2 minute MP3, I want to mute the time between 1:20 and 1:30. When saved back to a file, the rest of the MP3 will play normally -- only that portion will be silent. Any advice for setting this...

Transform map with multiple values to tree?

Given a randomly distributed set of keys, with each key mapped to a set of values, how would you transform it into multiple trees? Example Data Set NB2 => {NC2 ND2} ND1 => {NG1 NH1} NA1 => {NB1} NB1 => {NC1 ND1 NE1} NA2 => {NB2} NC1 => {NF1} NE1 => {NI1 NJ1 NK1} Resulting Tree for NA1 NA1 `-- NB1 |-- NC1 | `-- NF1 |-...

Does string.replaceAll() performance suffer from string immutability?

Lets say I called replaceAll() on a big string that replaced 1,000 matching instances. Does it mean that 1,000 strings were created and reassigned in process because of string immutability? Is there any faster alternatives? ...

Thread portability across Android Platforms

I understand that if you specify thread priorities other than the default in Java then it makes the program platform specific. If you were to create threads for an android application and modify the priorities then would the app platform specific across different android versions (i.e. Cupcake/Donut and modified versions of Android like...

Java Help: Using Classes

Now I have read and read on this but i am just stuck. Any help appreciated. I am looking for hints. The code compiles and runs fine but I don't think the variables are being stored in the employee class and I am not sure i am understanding my use of the constructor right. -Thanks Requirements: I have completed: Values are checked t...

Creating <rich:modalPanel> dynamically

How to create a rich:modalPanel dynamically? I need to click one button and generate a floating panel. The catch is, if I click the button, there should be created a second panel, and the first one should remain on its place. I've tried using ui:repeat and reRender, but this overwrites the first panel when I generate a second one. ...

mapping ipaddress range to country codes (data-structure hashmaps or trees?)

trying to solve a puzzle which i found here: http://zcasper.blogspot.com/2005/10/google-phone-interview.html the goal is to re-present a IP-Address range to country code look-up table in memory and use this data-structure to process a zilloin rows of ipaddress to identify the country code.. so i started with a shoot from the hip though...

Cost of using weak references in Java

Has anyone researched the runtime costs involved in creating and garbage collecting Java WeakReference objects? Are there any performance issues (e.g. contention) for multi-threaded applications? EDIT: Obviously the actual answer(s) will be JVM dependent, but general observations are also welcome. ...

JUnit4 + Eclipse "An internal error occured during Launching"

Hello I'm trying to run JUnit4 test cases on Eclipse 3.4.2 but it's not even starting for me. I am sure that I properly have junit-4.7.jar in my build path and the test application. Here is a simple example that illustrates my problem package test; import org.junit.Before; import org.junit.Test; public class UTest { @Test ...

What are good patterns / techniques to reduce verbosity of Java

One of the things that can be a little annoying about Java is the amount of code you need to express concepts. I am a believer in the "less code is better" philosophy, and I'd like to know how I can write Java without being so frustratingly verbose. Recently, I read the Hidden Features of Java question and was introduced to using double-...

Java: How to wait for all threads to finish?

I need to execute some amount of tasks 4 at a time, something like this: ExecutorService taskExecutor = Executors.newFixedThreadPool(4); while(...) { taskExecutor.execute(new MyTask()); } //...wait for completion somehow How can I get notified once all of them are complete? For now I can't think about anything better than setting ...

apple-jdbc-web server

Hi everyone !!! Plz i don't know if my post is in accordance with your policy...for any problem please i present all my desolations. I'm a bsc student in CIT . I have a project i which i want to use java applet and jdbc in a sort of host/client : My applet is working properly in the host but when i deploy it on apache webserver i lose ...

Java try catch problem

I'm currently writing an app for school that is a mini search engine. On execution, it indexes the contents of the text files included as args. I haven't used the try and catch methods before, and we were just given this code in include in our program: Scanner inputFile = null; try { inputFile = new Scanner(new File("dog.txt")); } c...

Accessing .exe file within .jar

Hi everyone! I recently created an application and successfully jarred this to c:/my/folder/app.jar. It works like a charm in the following case [Startup #1]: Open cmd cd to c:/my/folder java -jar app.jar But when I do this, it doesn't work [Startup #2]: Open cmd cd to c:/my/ java -jar folder/app.jar Because app.jar contains a ....

How can i get the console output generated by a exe file?

without using a redirect to file (">", ">>") ...

How can I set the file-read buffer size in Perl to optimize it for large files?

I understand that both Java and Perl try quite hard to find a one-size-fits all default buffer size when reading in files, but I find their choices to be increasingly antiquated, and am having a problem changing the default choice when it comes to Perl. In the case of Perl, which I believe uses 8K buffers by default, similar to Java's ...