java

Need help writing a regex

Hi folks! I'm trying to find the latter half of patterns of the following template: foo/BAR 'BAR' is the one I'm trying to retrieve. I tried with something like: \b(foo)/([a-zA-Z]+) This works fine, but this also matches http://foo/BAR - which I don't want. I also tried \\s(foo)/([a-zA-Z]+) but this doesnt match when the lin...

Using the Stanford postagger in java, getting java.lang.IncompatibleClassChangeError

I am trying to initialize the Stanford NLP Part of Speech tagger and I keep getting a java.lang.IncompatibleClassChangeError. When I print the cause of the error, I get null, when I print the message I get Implementing Class. This is my code: try { MaxentTagger tagger = new MaxentTagger(path+"left3words-wsj-0-18.tagger"); ...

What is the difference between Castor XML binding and JAXB binding

What is the difference between Castor XML and JAXB binding since both are binding java object to XML and vice versa. Updated : As using Castor I can do this Assume packageA.ClassA and packageB.ClassA have same attributes and class name just that they were located in different package. packageA.ClassA - > XML -> packageB.ClassA By ...

Returning String[] from a method

I want to return two values from a method stored in an array. How can I do it? For example: The method needs to return "un" and "pwd". ...

Drawing Graphs (charts) in JSF

Hi, How can I draw dynamic graphs in web pages in JSF ? People have suggested Google Chart Api I want something that can work offline ...

Read a large result set in chunks from mysql

I am trying to read a huge result set from mysql. Reading them in a straight-forward manner didn't work, as mysql tries to return all results together, which times out. I found the following piece of code which tells mysql to read the results back one at a time: stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql...

How to save content of a page call into a file in jsp/java?

Hi There, In jsp/java how can you call a page that outputs a xml file as a result and save its result (xml type) into a xml file on server. Both files (the file that produces the xml and the file that we want to save/overwrite) live on the same server. Basically I want to update my test.xml every now and then by calling generate.jsp th...

how to find the No. of matches if i use patterns and matcher in java?

i have the following code Pattern keyPattern = Pattern.compile(key); Matcher matcher = keyPattern.matcher(str); return matcher.replaceAll(value); this will replaces the key in the str with value; but i want to know how many instances of key's has been replaced with value. so how to know that? ...

Catch when java process has been terminated

How can I catch when somebody kills my application (java, but it is not important) by taskmanager or by taskkill console command? I understand that I cannot catch this IN my application but maybe I can do this by some hook with OS (windows of course). Maybe easyhook library (http://www.codeplex.com/easyhook) can help me, but I can not ...

How to use Session in Java Servlet?

Hi, I am having issues with session in my java code. Upon submitting a form via post, the java servlet will determine if the captcha is correct. May I know anything that I should add to use the session in java servlet? Is there any thing that I need to import to use session? protected void doPost(HttpServletRequest request, HttpServlet...

Pattern Matching in Java

I'm working on java program that can compute the differentiation of any given mathematical expression. When User types the expression say Sin(Cos(x^2)) I need to check whether it is mathematically valid or not. Of course we can do it by manual code writing but that would be tedious work. Can I do it using regex package of java?? How?? ...

Do too many plug-ins slow down Eclipse?

I have recently installed a new project into my Eclipse and also needed to install some plug-ins to manage it. I also installed other plug-ins which I do not need to manage the project but thought it will be nice to try out. After this, I noticed that my IDE isn’t as fast to respond as before. I’m not sure if it has something to do with...

How to identify a missing method (Binary Compatibility) in a JAR without running it?

I want to verify binary compatibility between 2 JARs. Following the suggestions in this answer I used jboss tattletale but it can find only missing classes. How can I find if there are missing methods? Is it possible at all? E.g. "Depends - on" class Foo depends on Bar (like many other middle class workers) import org.overlyusedcla...

j2ee application in tomcat

Hi, I've developed a j2ee application, now say sample.war is the file. When we port this to tomat webapps, it explodes to sample folder. But if we want to run this application for two people, how do we do that? some thing like http://address.com/user1/ and http://address.com/user2/ and in this we have different CSS (only the look varies...

Design pattern needed

Hi, I am going to develop a tool that will do the following: collect the files from remote server - periodically every few minutes. Export the collected files into a one single file. From the client, it sends a request to the server every 5 or 10 mins. Then server then sends a list of files. This part is called 'collection'. Afte...

Why is "public" not allowed for properties in JPA entities?

The JPA 2.0 specification says on page 22: The instance variables of a class must be private, protected, or package visibility independent of whether field access or property access is used. When property access is used, the property accessor methods must be public or protected. Why isn't public access allowed? ...

Java Generics: Who is right, javac or Eclipse compile?

Calling this method: public static @Nonnull <TV, TG extends TV> Maybe<TV> something(final @Nonnull TG value) { return new Maybe<TV>(value); } like this: public @Nonnull Maybe<Foo> visit() { return Maybe.something(new BarExtendsFoo()); } compiles just fine in Eclipse, but javac gives an "incompatable types" warning: found ...

how java.exe and javaw.exe are used in eclipse?

i know the use of java.exe and javaw.exe in command console.. but how they are used in eclipse? ...

Keep connection open for multiple web service requests

Hello, I would have question regarding web services. Let's say I have webservice client that has to perform under high load. And I cannot use another technology. Is it possible somehow to keep the connection open for all requests, to avoid overhead when establishing new tcp/ip connections? And in case of managed environment, is it possi...

What can cause this Java behaviour?

My project generates some text/binary files. If I run it normally, some files will have a pretty low size ( which indicates something went wrong ). If I run it from debug mode ( stepping through code ), the files will be generated correctly. What can cause this behaviour? I'm pretty sure I don't have any unclosed files. EDIT: I've gone...