so far I have seen two approaches of setting a variable’s value in Java. Sometimes a constructor with arguments is used, others setter methods are used to set the value of each variable. I know that a constructor initialises an instance variable inside a class once a class is instantiated using the R…
Tag: java
SEVERE: Context [/example] startup failed due to previous errors
I’m new at Java EE + Spring + Hibernate + Maven combination. Trying to make a simple project with tomcat 6.0. Our project just fine, no problem with debugging. But when i’m trying to run the server, it gives me “Error listenerStart” all the time. I searched all around the web for 3 day…
Getting ‘java.lang.UnsatisfiedLinkError’: no lwjgl in java.library.path
Note this is different from this question because it does not deal with linking because it’s not asking how to link it via the CLI, but the GUI in Eclipse. I have been trying to write a simple program using LWJGL. When I add the library to Eclipse (Kepler 4.3.1 on Windows 7 64bit) and write a program, i…
importNode throws org.w3c.dom.DOMException: NOT_SUPPORTED_ERR
I am trying to merge two XML documents both with standard Oracle JDK 7 and also with Saxon HE but I keep getting an: On the line with the importNode below (same thing happens with adoptNode BTW): I’ve tried both with Saxon-HE-9.4.jar on my classpath or not, but I still get the same error. update Based o…
Building a war on intellij
I have a Java EE project I have imported into IntelliJ . I can compile the project but for some reason not able to build a war artifact , when I go to the build tab the <build artifacts> option is blanked out ( ie I cannot select it ) . my project compiles fine but I am still confused
What does idempotent method mean and what are the side effects in case of calling close method of java.lang.AutoCloseable?
Java docs of close() method of java.lang.AutoCloseable says Note that unlike the close() method of Closeable, this close() method is not required to be idempotent. In other words, calling this close method more than once may have some visible side effect, unlike Closeable#close() which is required to have no …
Java says FileNotFoundException but file exists
I have an assignment for my CS class where it says to read a file with several test scores and asks me to sum and average them. While summing and averaging is easy, I am having problems with the file reading. The instructor said to use this syntax However, this throws a FileNotFoundException, but I have check…
Transaction marked as rollback only: How do I find the cause
I am having issues with committing a transaction within my @Transactional method: When I call methodB() from methodA(), the method passes successfuly and I can see “OK” in my logs. But then I get The context of methodB is completely missing in the exception – which is okay I suppose? Somethi…
Generic method to print arrays in java
I am trying to write a generic method printAll which prints an array of integer or character. Here’s the code: } Error: Exception in thread “main” java.lang.RuntimeException: Uncompilable source code – Erroneous tree type: <.any> Answer printAll(T[] t) will not accept primitive t…
How do I use the new computeIfAbsent function?
I very much want to use Map.computeIfAbsent but it has been too long since lambdas in undergrad. Almost directly from the docs: it gives an example of the old way to do things: And the new way: But in their example, I think I’m not quite “getting it.” How would I transform the code to use th…