Skip to content

fixed point arithmetics in java with fast performance

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 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…

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…

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…