493 Answered Questions for the topic Java

Java

04/25/19

Where does the @Transactional annotation belong?

Should you place the `@Transactional` in the `DAO` classes and/or their methods or is it better to annotate the Service classes which are calling using the DAO objects? Or does it make sense to... more
Java

04/24/19

Hibernate show real SQL?

if I set <property name="show_sql">true</property> in my **hibernate.cfg.xml** configuration file in the console I can see the SQL. But it's not *real* SQL... Can I see the SQL... more

04/24/19

represent a positive integer x as the sum of numbers each to the power k. For example, 25 = 3^2 + 4^2.

I need to write a function in Java which would represent a positive integer x as the sum of numbers each to the power k. For example, 25 = 3^2 + 4^2. So, once I feed 25 and 2 as arguments in it, I... more

Incrementor logic?

I'm trying to get deeper with post and pre incrementors but am a bit stuck with the following expression : public static void main(String[] args) { int i = 0; i = i+=(++i + (i+=2 + --i) -... more
Java

04/24/19

How to calculate the area of a java.awt.geom.Area?

I am looking for a way to calculate the area, in pixels, of an arbitrary instance of `java.awt.geom.Area`. The background: I have `Shape`s in my applications that may overlap. I want to know how... more
Java

04/22/19

IntelliJ show JavaDocs tooltip on mouse over?

In Eclipse, when hovering over a method, variable, etc. a tooltip is displayed with the corresponding JavaDocs. Is there such a feature in IntelliJ?
Java

04/21/19

How convert simulink files to XML?

I need convert an Simulink file (.mdl) to an XML file, after any searches i'm not found any content to help me with this problem. You'd know some way or ready solution for this in Java?
Java

04/19/19

SQL parser library for Java?

Is there an open-source Java library for parsing SQL statements? If possible, it should be customizable or flexible enough to also be able to parse (or at least ignore) vendor-specific syntax... more
Java

04/19/19

How can I convert my Java program to an .exe file?

If I have a Java source file (\\*.java) or a class file (\\*.class), how can I convert it to a .exe file?I also need an installer for my program.
Java

04/18/19

Geometry library for Java?

Is there any geometry library available for Java? I'm looking for solution to get an intersection point(s) between two geometry objects.
Java

04/18/19

How to get the path of a running JAR file?

My code runs inside a JAR file, say foo.jar, and I need to know, in the code, in which folder the running foo.jar is.So, if foo.jar is in `C:\\FOO\\`, I want to get that path no matter what my... more
Java

04/17/19

Can enums be subclassed to add new elements?

I want to take an existing enum and add more elements to it as follows: enum A {a,b,c} enum B extends A {d} // B is {a,b,c,d} Is this possible in Java?
Java

04/17/19

Parsing Simulink models?

We are looking for a library to parse Simulink model. We have found a python library but no Java solution. Are there any open source libraries that can parse Simulink 2012a models?

Can I add listeners/publisher subscriber to JAXB objects?

I have a multithreaded application using JAXB. The JAXB object represent state of other system hardware. I have a thread monitoring the system hardware, and it updates the JAXB objects with the... more
Java

04/17/19

Is there anything like .NET's NotImplementedException in Java?

Is there anything like .NET's `NotImplementedException` in Java?

04/14/19

In Java, what are the boolean "order of operations"?

Let's take a simple example of an object `Cat`. I want to be sure the "not null" `cat` is either orange or grey. if(cat != null && cat.getColor() == "orange" || cat.getColor() == "grey")... more
Java

04/14/19

Getting a File's MD5 Checksum in Java?

I am looking to use Java to get the MD5 checksum of a file. I was really surprised but I haven't been able to find anything that shows how to get the MD5 checksum of a file.How is it done?
Java

04/14/19

How to solve OutOfMemoryError when building a PDF System Design Description for a "big" Simulink Model?

Introduction I get an `OutOfMemoryError` when building a `System Design Description` in `PDF` and `Word` format. Steps resulting in Exception I have already increased the heap space to the maximum... more
Java Linux

04/14/19

Error: Could not find or load main class?

I am having trouble compiling and running my Java code, intended to allow me to interface Java with a shared object for Vensim, a simulation modeling package. The following code compiles without... more
Java

04/13/19

Run a single test method with maven?

I know you can run all the tests in a certain class using: mvn test -Dtest=classnameBut I want to run an individual method and -Dtest=classname.methodname doesn't seem to work.
Java Autocad Dxf Dwg

04/13/19

AutoCAD library in Java to read .dwg files?

Is there any open-source Java or JavaScript library available to parse .dwg files and get the objects from it. I would like to extract data from a table of text for my project. It seems that the... more
Java

04/12/19

Change date format in a Java string?

I've a `String` representing a date. String date_s = "2011-01-18 00:00:00.0"; I'd like to convert it to a `Date` and output it in `YYYY-MM-DD` format > 2011-01-18 How can I achieve this?
Java

04/11/19

When would you use the Builder Pattern?

What are some *common*, *real world examples* of using the Builder Pattern? What does it buy you? Why not just use a Factory Pattern?
Java

04/11/19

Why is the Java main method static?

The method signature of a Java `main()` method is: public static void main(String[] args) { ... } Is there a reason for this method to be static?
Java

04/10/19

Safely casting long to int in Java?

What's the most idiomatic way in Java to verify that a cast from `long` to `int` does not lose any information? This is my current implementation: public static int safeLongToInt(long l) { int... more

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.