I am using the latest spring-data-mongodb (1.1.0.M2) and the latest Mongo Driver (2.9.0-RC1). I have a situation where I have multiple clients connecting to my application and I want to give each one their own “schema/database” in the same Mongo server. This is not a very difficult task to achieve…
Duplicating objects in Java
I learned that when you modify a variable in Java it doesn’t change the variable it was based on I assumed a similar thing for objects. Consider this class. After I tried this code I got confused. Please explain to me why changing any of the objects affects the other one. I understand that the value of …
ArrayList input java
Im looking at the problem: Write a program which reads a sequence of integers and displays them in ascending order. Im creating an ArrayList (which I am new to) and I want to populate with integers input from the command line. With an array I could use a for loop with but with an ArrayList of unbounded size I…
Very slow debugging in Eclipse
I try to debug Jonas webapp under Eclipse. Unfortunately when I connect to the remote application everything works terriblly slow (also after killing all java applications and restarting the PC). I use also JRebel. What might be the cause of such behaviour? Answer You could also try using the Java Monitoring …
How do I write the exception from printStackTrace() into a text file in Java?
I need to capture the exception in a text file in Java. For example: Using getMessage() works, but it only shows the error message. I want all the information in the printStackTrace() including line numbers. Answer It accepts a PrintStream as a parameter; see the documentation. See also Difference between pri…
Refresh elements of GUI in java
I’m new to GUIs in java. For example, I need to update just 1 element (e.g., JLabel). In Tkinter I would use something like root.update() or root.update_idletasks(). I wonder if a similar simple function exists in for applications made with swing. I’ve tried gui_element.SetVisible(false) and gui_e…
Jackson JSON custom serialization for certain fields
Is there a way using Jackson JSON Processor to do custom field level serialization? For example, I’d like to have the class serialized to the follow JSON: Note that age=25 is encoded as a number while favoriteNumber=123 is encoded as a string. Out of the box Jackson marshalls int to a number. In this ca…
How to nicely lay out a tree in the form of a table (using merged cells)
Background: I have some data that I want to present in a table. Each column in the table has a header. Some of these headers in turn, have common headers. In other words, I have a tree of headers that …
Specify the GRADLE_USER_HOME in Windows 7
How do I configure the GRADLE_USER_HOME option? My Windows username contains a space(C:UsersBaz Foo) and I think that the build fails because of this. I have added an environment variable GRADLE_USER_HOME and set it to C:UsersBaz Foo.gradle and tried also with –gradle-user-home=”C:UsersBaz Foo.gra…
Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 1000000 at problem2.main(problem2.java:17)
I get the following error and I don’t know why. I tried looking it up, but I didn’t find a solution. Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 1000000 at problem2.main(problem2.java:17) Here is my code: Answer The problem is not the size of the int[]. Your wh…