java

JNA load .a/.lib library

Hi, i'm trying to write jna mapping for libfaad2. The library uses mp4ff for parsing mp4 files. mp4ff is compiled into libmp4ff.lib on windows and libmp4ff.a on linux. JNA only looks for .dll/.so files. So how can I load this mp4ff into jna? EDIT I think this question has the answer. I hate AAC, I've spent 4 days debugging invalid memo...

Plot Graphs in Java

The java Swing GUI im developing needs to plot a 2D graph based on the x and y coordinates generated in the program. Is there a Swing component for that? Or is there any other open source package for the purpose? Thanks in Advance.. ...

How to push GridbagLayout not to lay components in the center of JPanel

the problem is in centered layout of components, GridBagLayout always 'sits' in center of JPanel, so I don't care how it will layout components inside, my problem is where these components will start laying out on a panel. I tried with: panel.setAlignmentX( JPanel.LEFT_ALIGNMENT ); but it did not helped. Any idea? ...

Java Regex Replace with Capturing Group

Is there any way to replace a regexp with modified content of capture group? Example: Pattern regex = Pattern.compile("(\\d{1,2})"); Matcher regexMatcher = regex.matcher(text); resultString = regexMatcher.replaceAll("$1"); // *3 ?? And I'd like to replace all occurrence with $1 multiplied by 3. edit: Looks like, something's wrong :...

SWT. How to create Composite object witout parent

Hi, I write a project in Java using SWT. I would create temporary container for some controls. How to create composite control without parent object? Sincerely, mykhaylo ...

Starting a Java agent after program start

Is it possible to insert a javaagent after virtual machine start from within the same VM? Lets say for example we have an agent in a jar myagent.jar with the appropriate meta data set-up and an agentmain method already implemented. Now the users program calls an API call which should result in the insertion of the agent so that it can r...

Do generics in Java avoid all ClassCastExceptins?

Since generics are only checked during compile time with Java 5, can they avoid ClassCastExceptions in all situations? ...

How do I refer to Java 1.6 APIs while degrading gracefully against Java 1.5?

I would like to use the java.text.Normalizer class from Java 1.6 to do Unicode normalization, but my code has to be able to run on Java 1.5. I don't mind if the code running on 1.5 doesn't do normalization, but I don't want it to give NoClassDefFoundErrors or ClassNotFoundExceptions when it runs. What's the best way to achieve this? ...

Use Tomcat with Java SecurityManager?

I'm writing a web application that is supposed to run on Tomcat on Ubuntu. On Ubuntu, Tomcat is per default configured to run with the Java SecurityManager. Besides my own web application, there will only be some well known third party web applications related to my own, like the BIRT report engine. If one of the web applications fails ...

How to configure Java SecurityManager to allow to read all properties from given file

I'm currently trying to create a policy file for the Nexus repository manager running on Tomcat. Nexus tries to read the file WEB-INF/plexus.properties (for which I already granted permission), and seems to try to read all properties from there, which fails because it is missing the following permission: java.security.PropertyPermissio...

FMJ Webcam capture example

I've been searching for while now and I can't find a simple example of how to capture a webcam stream with FMJ. Are there any tutorials or examples available which could help me? ...

Nullpointer exception

There is a possiblity that this may be a dupicate question. I initialize a String variable to null.I may or may not update it with a value.Now I want to check whether this variable is not equal to null and whatever I try I get a null pointer exception.I can't afford to throw nullpointer exception as it is costly.Is there any workaround t...

A class which implements mouseLIstener and mouseMotionListener in java...

Hi all. I have a question about a class which implements both mouseListener and mouseMotionListener in java. I've recently been splitting up my mouse listeners into different modes in this game I'm making in java, and came across a funny issue when dealing with the Build Item listener. For the game panel, I used two methods to reset t...

Maven2 compiler custom execution source directory and target directory

I want to run the maven compiler plugin in a different phase and with different sourceDirectories and destinationDirectories such that code from directories other than src/main/java and src/test/java can be used. I thought the solution would look something like the below, where the phase I was linking it to was pre-integration-test. How...

How can I get the count of line in a file in an efficient way?

I have a big file. It includes approximately 3.000-20.000 lines. How can I get the total count of lines in the file using Java? ...

Table Name Troubles With Hibernate Named Query

Hi all, I've got the following named query in Hibernate: <sql-query name="CreateLogTable"> CREATE TABLE IF NOT EXISTS :tableName ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `url` VARCHAR (750) NOT NULL, `query` VARCHAR (500), `ipaddress` VARCHAR (39), `datetime` DATETIME NOT NULL, `hits` MEDIUMINT UNSIGN...

Should I set the initial java String values from null to ""?

Often I have a class as such: public class Foo { private String field1; private String field2; // etc etc etc } This makes the initial values of field1 and field2 equal to null. Would it be better to have all my String class fields as follows? public class Foo { private String field1 = ""; private String field2 = ""; // etc etc et...

Java Regex Replace with Capturing Group

Is there any way to replace a regexp with modified content of capture group? Example: Pattern regex = Pattern.compile("(\\d{1,2})"); Matcher regexMatcher = regex.matcher(text); resultString = regexMatcher.replaceAll("$1"); // *3 ?? And I'd like to replace all occurrence with $1 multiplied by 3. edit: Looks like, something's wrong :...

Why i should use ActiveMQ for send emails ?

Hi, many weeks ago recommended me for send emails, ActiveMQ. So i search information about this, but i don't understand totally how this works. Could someone explain me why i should use ActiveMQ for send emails ? ...

Hiding a view servlet in a Java MVC web application?

I'm using a very simple MVC framework, Bear Bibeault's Front Man, which, for those not familiar, is pretty similar to Spring MVC (in concept at least). For most cases, I am using a JSP as my view. To prevent direct access to the view, I place the JSP files inside the WEB-INF directory. However, in some cases I need to use a servlet to ...