My while loop won't stop with a break?

if (sum < 6) { System.out.println("You win"); System.out.println(); // Does the user want to retry? System.out.print("Would you like to retry?(Y or N) : "); String retry = input.nextLine(); while (true) { // If the...
more »

2017-05-14 23:05 (1) Answers

Java8 retrieving lambda setter from class

I'm trying to get a lambda method handle for the setter of a private field, but for some reason, the setter cannot be found. This is the functional interface I am using: @FunctionalInterface public interface ISetter<T, R> { void set(T obj...
more »

2017-05-14 20:05 (1) Answers

Alternate to mvn spring-boot:run

I have a spring boot application which I run using: mvn spring-boot:run and this works perfectly fine. I want to run this application using java -jar option and when I run it: java $JAVA_OPTS -jar target/backend-1.0-SNAPSHOT.jar --server.port=8...
more »

2017-05-14 19:05 (2) Answers

Drawing a Path with multiple colors

I am drawing on android.graphics.Canvas using android.graphics.Path. I want to allow the user to draw using a range of colors and stroke widths, however, whenever the color or stroke width is changed, everything is re-drawn using the new color or str...
more »

2017-05-14 19:05 (3) Answers

Jersey hides Spring framework and SockJS

We're trying to expose sockjs endpoints with Spring Framework WebSocket support. This is the configuration on the server side where Jersey is managing the routes: @Configuration @EnableWebSocket public class WebSocketConfig extends WebSocketMessage...
more »

2017-05-14 16:05 (0) Answers

OpenCV can't detect color red correctly

Recently, I'm trying to use java OpenCV to detect the color of a Rubik's Cube. My Rubik's Cube has six colors including white, yellow, orange, red, blue and green. The color space I use is HSV color space. According to Wiki, each color has their uniq...
more »

2017-05-14 16:05 (0) Answers

Treating "N/A" value as null with Jackson

I am getting data from an external JSON API and parsing the result with Jackson. Unfortunately, that API returns all fields as String and those are filled with "N/A" when data is unavailable. I would like to replace those fields with null, especiall...
more »

2017-05-14 15:05 (1) Answers

Hibernate validations on save (insert) only

We encountered a problem with legacy code. There is a validation set for a "username" field, validating its length and making sure it contains at least one letter: @Column(name = "username") @Size(min = 4, max = 40) @Pattern(regexp = "^.*[a-zA-Z]+.*...
more »

2017-05-14 14:05 (1) Answers

How to parse multiple integers

So I want to parse multiple integers by dividing them by , or space. Let's say user is only allowed to enter 4 numbers max. So how do I make multiple check if user enters for instance ( 1 2 4 3 ) or (1 2 3)? Because it would be not smart to make chec...
more »

2017-05-14 12:05 (1) Answers

selenium java add cookies

Eclipse giving error,Date is deprecated.Can anyone please help to sort this out, My code is following Using stored cookie to login into the script. File file = new File("Cookies.data"); FileReader fileReader = new FileR...
more »

2017-05-14 11:05 (1) Answers

Spring 3.0.5 Hibernate Maven Error

I am trying to learn spring , maven and eclipse. I got this issue. I am trying to set up Spring + Hibernate Maven web project. When i start server and open the jsp page i get this error. I have searched a fix for this issue but most of answers is re...
more »

2017-05-14 11:05 (1) Answers

Rotation Of An Image In JLabel - Java

I am currently making a game with Java. I added an image to the screen using a JLabel and I want to know how to rotate it. I have done a lot of research but have not found anything useful. Can I have some help? Here is my code: (Code from first cla...
more »

2017-05-14 00:05 (1) Answers

Android Studio - Custom ListView Crashing

So, recently followed this video's instructions on how to make custom ListView: https://www.youtube.com/watch?v=D0or0X12FMM The program is crashing on startup, its DOA and show's nothing before it crashes. It's not logging any errors to the console...
more »

2017-05-14 00:05 (1) Answers

Makefile to compile java in directories

I would like to create makefile that will compile java files which are in specific directory. Here is what I've got: JCC = javac JCR = java JFLAGS = -source 1.6 \ -target 1.6 \ -d out main: folder all all: $(JCC) $(JFLAGS) src/com/...
more »

2017-05-13 22:05 (1) Answers

Why my webpage displays ???? instead of contents

I have used Resource Bundle editor to create _hi(Hindi language) locale properties file in eclipse. My problem is that if I run my webpage, it displays ???? instead of Hindi content. I have provided code below. It works fine with french language ...
more »

2017-05-13 16:05 (0) Answers

Return array for box

working on the code below. I want return the values of the two elements as arrays. public static int[]box ={20,50,60}; public static int[] getBoxDimensions(int[]box){ int[] dimension; int length = box[0]; int width = box[box.length - 1]; ...
more »

2017-05-13 12:05 (1) Answers

java 8 optional to replace return null

I am refactoring the code to Java 8 and I want to replace null checks with Optional. public Employee findEmployeeById(String id) { List<Employee> empList = .. //some db query return (empList.isEmpty() ? null : empList.get(0)); } Opti...
more »

2017-05-13 11:05 (4) Answers

Transparent action bar and status bar like Uber

I've done a few researches on this topic but I couldn't found some solution for my App/ Activity. I have tried to get a transparent action bar. First, I have tried to change the themes in my AndroidManifest.xml: values/styles.xml: <style ...
more »

2017-05-13 09:05 (6) Answers

Eclipse class not found exception

I am facing some challenges in Eclipse please help me. from last 5 years I am using visual studio but due to my academic requirement I am learning java and recently I installed eclipse in my machine and when I am modifying some code and trying to exe...
more »

2017-05-13 00:05 (0) Answers

Java coding style in Eclipse

For each method, I want to add a space between the method name and the right curly bracket. For example, public void setName(String name) { } I want a space between ) and {. Is it possible to automatically set this in Eclipse or somewhere? It's an...
more »

2017-05-12 23:05 (4) Answers