Skip to content

Find all objects in collection Java Mongodb

Below code finds the first document in a collection : There does not appear to be a findAll method. How to find all the documents in the collection testCollection ? Answer You have to use the DBCollection.find() method, which Select all documents in collection and get a cursor to the selected documents. So, w…

Java SWT make a Label Scrollable

I have a Label in a Group in SWT and if it contains many lines of text, I would like to make it scrollable vertically. Setting the style parameter with SWT.V_SCROLL doesn’t seem to do it. How can I do this? Answer Label does not support scrolling. You could use a read only Text control which will scroll…

Fibonacci calculator with BigIntegers

I’m working on a homework project where I must have the user input a number, and the computer spits out the Fibonacci numbers up to that one. I’d normally be able to do this, with int values, except that for this program, I need to use the BigInteger type instead, because int, long, double, etc. t…

Mockito NotaMockException

I am facing an issue with Mockito junit testing. I am new to it and am a bit confused with the problem I am facing. Any help on this would be appreciated. Getting exception : in the below code I am aware that activity is not a mock but I am not sure for a way around this as secondMethod()

How can I set the compileOptions for my Gradle Java plugin?

I want to set the -parameters command on my gradle build so that I can use reflection to access the name of the parameters. It seems like I should be doing this with the following closure. But compileOptions is listed as read-only, and when I look at the source code there’s no setter. https://gradle.org…

SpringBoot with Thymeleaf – css not found

First to say is that I’ve been searching for a solution for a while now and I’m quite desperate now. I cannot get the css file to be accessible from html page when run by Spring Boot. html.file Application.java folder structure: I’ve tried putting the css folder into a static folder and/or r…

Hadoop 2.6.0 Browsing filesystem Java

I have installed a basic hadoop cluster on CentOS 6.6 and want to write a few basic programs (browse the filesystem, delete/add files, etc) but I’m struggling to get even the most basic app working. When running some basic code to list the contents of a directory to the console I get the following error…