I need to represent some numbers in Java with perfect precision and fixed number of decimal points after decimal point; after that decimal point, I don’t care. (More concretely – money and percentages.) I used Java’s own BigDecimal now, but I found out, that it’s really slow and it sta…
How can I inject an EJB from another application on the same GlassFish Server?
I have two applications running on my local glassfish server. One to rent bicylces and one to buy train tickets. I now wanted to call a remote ejb from the train application to allow the rental of …
How to run TestNG from command line
How exactly do I run a .java TestNG project from a command line? I have read through the TestNG documentation, and tried the following to no avail: … with the following testng.xml file in my project: The error I get is this: Obviously, I am not referencing TestNG correctly in my command line. Does anyon…
VisualVM launcher error
I’m trying to use the Eclipse VisualVM launcher. It seems pretty nice, except that it seems to spawn an instance if VisualVM too late to do any profiling of my application. My application finishes execution before the profiler is even initialized; once it starts up, an error window pops up, saying: cann…
wsimport – Two declarations cause a collision, same line given
Trying to use wsimport to generate a client for a SOAP endpoint. The WSDL and all XSD files used are local copies. This is the command being executed: Which gives this error: Note the line number is the same for the reported collision. Here’s the schema: I’ve tried removing the type definition, bu…
Call java class method from jar (not main)
Is this possible to call a specific method (other than main) of a class in a jar file from command line? Answer If you are talking about running Java code from the command-line, then no. You can specify a class name, but not which method to call, that always has to be public static void main(String[] argv). W…
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
I made some Java 1.6-Oracle11g-JDBC (using OJDBC 6) code (below). I am getting an exception – java.sql.SQLException: Missing IN or OUT parameter at index:: 1 Why is this happening and how do I fix it ? My output is- The code is- EDIT – To correct the code, we use- //insert 1st row //insert 2nd row…
How to get the attribute value of an xml node using java
I have an xml which looks like this: Here I want to retrieve the value of “source type” where type is an attribute. I tried the following, which didn’t work: This also didn’t work: Answer Since your question is more generic so try to implement it with XML Parsers available in Java .If …
Save an integer in two digit format in a variable in Java
How can I store an integer in two digit format in Java? Like can I set and print it as 01? Also, not only printing, if I say int b=a;, b should also print its value as 01. Answer I think this is what you’re looking for: Or, more briefly: An int just stores a quantity, and 01 and 1
Eclipse IDE Scope Highlighting?
When I first learned Java, I was using an IDE called “BlueJ.” It had this feature called “Scope Highlighting” which made it very easy to read blocks of code. Now I’ve moved on from BlueJ and began using Eclipse. I’m currently in the process of customizing Eclipse to my liki…