java

Get annoted hibernate tablename from POJO

Hi guys, I have an entity which is declared roughly like: @Entity @Table(name = "myUserTable") public class User implements Serializable { ... } I'm making a generic DAO class, and in doing so I'd like to retrieve the "myUserTable" name. Is there any way I can reach this name? Cheers Nik ...

Java RPN (Reverse Polish Notation) infix to postfix

I am pretty sure, that stacks are used for building PRN and '(' are ignored, but it does not seem to be the case. For example: input 1: 52+(1+2)*4-3 input 2: 52+((1+2)*4)-3 input 3: (52+1+2)*4-3 Input 1 and input 2 output should be the same, and input 1 and input 3 should differ. output 1: 52 1 2 + 4 3 - * + output 2: 52 1 2 + 4 * ...

Getting the class of a Java generic, and interface implementation of generics

Hi guys, I'd like to make a class that looks basically like this: public class MyClass<T implements Serializable) { void function() { Class c = T.class; } } Two errors: - I cannot call T.class, even though I can do that with any other object type - I cannot enforce that T implements Serializable in this way How do I solv...

What is an interface in Java?

Just as a counterpoint to this question: what is an interface in Java? ...

Java Web Service Constructor invocation

How do you invoke a Java Web service constructor. Ideally when does constructor invocation happen while you consume the service from a client ...

How do I detect if a remote web page is avaliable

Hi, I need to check if a web page hosted on a remote server via tomcat is deployed or not.There may be a case where the page is not deployed and I need to capture this. I've tried with URL connection but I guess that is only useful for verifying if tomcat is up or down on the remote system. How can I go about verifying whether the page...

JDBC Thin Oracle 11g

Hi all, I am using oracle 11g. I write code to connect oracle database with java 1.6, but I can't connect to it. When configure the guide line to below: I have ojdbc6.jar,orai18n.jar, and class12.jar I set: Class_Path: %ORACLE_HOME%\jlib\orai18n.jar;r;%Oracle_home%\jdbc\ojdbc6.jar After that I run sample java code connect to oracl...

Closing JFrame of java applet using buttons on the system frame causes delay

I have written a java applet which opens a JFrame (so when run in the browser, it will popup a small new window). The problem is, when pressing one of the buttons of the window frame, there is a slight delay (cannot move the mouse for 2 or 3 sec) before the window will close/minimize/maximize. The hidden menu actions (accessed when pres...

When registering for Java events, are duplicate listeners typically allowed?

Should an addListener method check for duplicate registrations when called? If so, what should happen when a duplicate is found? final public class exampleCanFire { public void addFooListener(FooListener listener) { // Before adding listener to private list of listeners, should I check for duplicates? } } ...

How to group in regex

I have this input string(oid) : 1.2.3.4.5.66.77.88.99.10.52 I want group each number into 3 to like this Group 1 : 1.2.3 Group 2 : 4.5.66 Group 3 : 77.88.99 Group 4 : 10.52 It should be very dynamic depending on the input. If it has 30 numbers meaning it will return 10 groups. I have tested using this regex : (\d+.\d+.\d+) But th...

What's the best way to get text user-interfaces (ncurses-like) functionality in Java?

I need to implement a console application (possibly in Java) with ncurses-like functionality (such as navigating a menu and redrawing the whole screen). The only solutions that I can find to do this so far are CHARVA ("A Java Windowing Toolkit for Text Terminals"), tuipeer ("A Text User Interface for the Java AWT" and a really old Dr. Do...

Struts forEach tag not iterating through ArrayList

I have some code! The code looks like this: <c:forEach var="element" items="%{serviceList.getServices()}"> <p>Hello!</p> </c:forEach> "serviceList" is a bean, with a method on it called getServices(). getServices() returns an ArrayList, so I naturally assumed that the above code would take the arraylist, and iterate through it...

Creating JUnit tests for database items with auto generated keys

I have a class with a primary key that is stored in a database. When creating a new instance of the class it can either be fetched from the HSQLDB database or for items not in the database it inserts everything but the primary key and this is autogenerated and returned to the class to set the id attribute. I then have a getID() method to...

Can not get key from KeyStore

Hi all I try to get Key from KeyStore. I created a keystore by Keytool: keytool -genkeypair -dname "cn=Mark Jones, ou=JavaSoft, o=Sun, c=US" -alias business2 -keypass abcdtest -keystore C:\workspace\XMLSample\keystore\mykeystore.jks -storepass 123456 And the following is GenerateXML.java import java.io.FileInputStream; import java...

Java Web Service operation

I have a set of statements to be executed repeatedly every time a web method is called with a new service.I tried writing in the constructor but, the constructor gets invoked only once when the server starts. Instead, I need the set of stmts to be executed each time a Service is created at the client. ...

Waiting for a Timer to finish in Java

I'm using java.util.Timer to schedule a periodic task. At one point, I'd like to shut it down, and wait for it to finish. Timer.cancel() will prevent any future tasks from running. How do I make sure any tasks are not running at the moment (or wait for them if they are?) I can introduce external synchronization mechanisms, but I don't ...

Java Native Interface and Security

Is there any chance for the the violation of java security policy through java native interface. Which are the main areas we have to use JNI ...

JDBC Query excecution

I am facing an issue while executing queries.I use the same resultSet and statement for excecuting all the queries.Now I face an intermittent SQlException saying that connection is already closed.Now we have to either have separate resultSet for each query or have lock like structure.Can anyone tell which is better.I think introducing lo...

Most specific method with matches of both fixed/variable arity (varargs)

In section 15.12.2.5 of the Java Language Specification, it talks about how to choose the most specific method in both cases of methods with fixed arity and methods of variable arity (i.e. varargs). What I can't find in the JLS is anything about deciding between two methods where one is of fixed arity and one of variable arity however....

IllegalAccessError when calling ant script from maven-antrun-plugin

I just updated Maven from 2.0.9 to 2.2.1 and I'm getting the following exception when running a maven build: INFO] [antrun:run {execution: precompile-jsp}] [INFO] Executing tasks default: jspc: [mkdir] Created dir: C:\builds\trunk\webapps\vyre_portlets\WEB-INF\jsp_src [INFO] -------------------------------------------------------...