Newest java Questions

Q&A for professional and enthusiast programmers

How to Properly Implement a Custom Loading Screen in Java

I am trying to make a custom loading screen in Java (not using the JProgressBar). Right now I have just tried making a loading bar that slowly fills the screen left to right with a black rectangle. To ...

How to read AI and Sketch files in Java?

How to read elements (artboards, texts, fields etc.) and sizes in AI and Sketch files with Java? Maybe there is aspecial library?

Jackson: choose children class for deserialization depending of field existence

I have the following model: public abstract class A { String commonField; } public class B extends A { } public class C extends A { String customField; } How to tell choose class (B or ...

Android TextView Marquee Programaticly

I am attempting to display a list of textviews but need them to all Marquee, have some code Activity (XML) somewhere that Marquee's, but don't think I can use it here. LinearLayout layout = (...

how to find average chain length in a linked list

So I am trying to get the average chain length from a linked list. I have a linked list with all the staff in. The method is the chainAverage. I need to iterate through the linked list and then find ...

Access to my application context from QuartzJob

I don't know how to access to the original context of my application from a Quartz Job. I can see that both context are not communicated because I am trying to inject a DAO bean as a property of my ...

Getting NumberFormatException [on hold]

I am working on RPN PostFix Calculation . I am getting NumberFormat Exception at line "Double i =Double.parseDouble(token+"");". I am a novice in programming, Any help would be appreciated. enter ...

Override classloading for a specifc java class file in a wildfly/jboss module

I want to overwrite a particular java class present in a JBoss/Wildfly module with my own customizations. If this is a tomcat server all I need to do is place the customized class files in WEB-INF/...

Received fatal alert: bad_certificate in Java

Am trying to establish an SSL conection to a server. I have created a Keystore and imported the server's certificate as well as mine as trusted entries. The server guys also have imported my ...

Java code says: nullPointerException [duplicate]

I have this very simple code: public class Player{ private int x,y,velX,velY,width,height,id; private boolean isControllable; public Player(int _x,int _y,int _width,int _height,int _id,boolean ...

Dynamic mime mapping Wildfly / Undertow

I would like to serve static content. I have configured undertow as Wildfly 10 subsystem. And it works. But it dosent serv mime type in http header. I know that I can use mime mapping, file extension -...

Parsing String to ASCII only [on hold]

I have a regular Java string like: Nørmäl. In order to comply with an an API I have to remove the special characters. I want to replace them so I get either Normael or Normal. I could do this by using ...

Android getSupportFragmentManager().findFragmentById() returns null sometimes

I'm developing ad android application and after an http call I'm using a ResultReceiver to get the result in my MainActivity. I read many articles about this problem but none of them was specific to ...

Setting a radio's id from a s:property value

I'm trying to set the id of my radio button dinamicaly from a value inside a bean. Here's my sample : <s:iterator value="resultatInterlocuteurADP.list" status="resStatus"> ...

Spring Security Logout() Doesn't Works , API's still accessible

I am working on a spring-data-mongodb , Spring Security & spring-data-redis but facing issues in Logging out from current session, Since on calling /logout (By default) I am still able to access ...

Show certain text in TextView Single Line

For example, this is the original string s Google Android Gmail Youtube Apple iOS <TextView android:id="@+id/text" android:layout_width="match_parent" android:...

Java bug not writing arabic text

Hi i noticed this bug recently which has been seriously bugging me so basically i have this function to write my json to a .json file or txt what ever you want but what's weird is when i run this in ...

Cannot initialize UART service on Android

I am developing mobile app which working with sensor, that use UART. Example from official github page works perfect, but code extracted from doesnt work. Only thing that i have changed, is a device ...

How to parse Java object using Gson and get values of each element?

title = u.getOrganizations(); Gson gson = new Gson(); String jsonItems = gson.toJson(title); System.out.println(jsonItems); if(jsonItems.length() >0 && !jsonItems.equalsIgnoreCase(null)){ ...

Creating a new Table - No suitable driver found

I'm trying to learn how to make an SQLite database with this tutorial http://www.sqlitetutorial.net/sqlite-java/create-table/ but I'm stuck. I wrote the code like they said (changing just the name of ...

RCP application thows “Problems occurred when invoking code from plug-in”

!ENTRY org.eclipse.ui.workbench 4 2 2015-07-09 03:06:34.140 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench". !STACK 0 java.lang.NullPointerException at org....

Programatically Compile multiple files when some has error

I have to programmatically compile thousands of dynamically generated Java Files. Some of these files may have dependencies with others; but this is not a requirements so there may be simple isolated ...

Use SortedSetDocValuesField to sort multiple fields - Error: unexpected docvalues type SORTED_SET for field

I am just implementing a search with Lucene 5.5.0 for a JSF web application. In the application, several user can edit documents and very simple (only date and user name) editing journal will be ...

Conditional Style Not working in Dynamic Reports

I have a requirement like first row of a group should come in light color. for this I implemented ConditionalStyleBuilder in a sample example and it worked fine. But when i implemented same in my ...

Why is my code not working? [on hold]

I am trying to generate an integer that will display random number from 1 to 12 and then repeats it 100 times. This is my code so far that is not working. Random randomGen = new Random(); int ...

how to force maven to target java 1.7 with a javax.persistence dependency?

I am setting this in the pom.xml file: <properties> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </...

Zookeeper Hbase Issue

I have a 3 node HBase cluster (Hostname - 26 primary, Hostname - 58 secondary and Hostname - 82 tertiary) with Zookeeper and the underlying data store is Hadoop. 1) When I checked in the zookeeper ...

Not able to read value from properties file in Spring Boot using @Value annotation

I am not able to read a property from properties file through Spring Boot. I have a REST service which is working through the browser and Postman both and returning me a valid 200 response with data. ...

Infinite loop during user's selection with switch case and while loop

I am trying to make a CLI with user input to choose from the options available. I am using a switch and while loop to ensure that it can go back to main menu after choosing an option. The problem is ...

How to use a YouTube player view in a fragment

i currently develop app that get the items of playlist and display it in a listview in a fragment and it should if i click an item of the list open another fragment in the same activity with youtube ...

resol vbus java master

Sorry by my English, I am trying to connect with an RESOL-VBus device and obtain some data from it over TCP protocol. I am trying to use the resol-vbus-java-master library that can be used(between ...

When encrypting 2 Strings with XOR in Java, what is key[i % key.length]

I'm trying to understand "encrypting" 2 Strings with XOR in Java, I've found pretty clear example but I can't understand why they are doing this: input.charAt(i) ^ key[i % key.length] How in "human ...

understanding TicTacToeAi with Negamax algorithm

private int NegaMax(int p) { int End = GameOver(); if (End != 0) return End; int best_value = (p == 1) ? 512 : 2048; for (int b = 1; b <= 256; b = b <...

Return array vs fill array

I've seen two general types of methods whose goal is to return an array of values. The first is the most obvious: public double[] getArray() { ... return ...; } However, I've also seen ...

ElasticSearch hasFailures() equivalent for JEST

What is the JEST equivalent for elasticsearch's hasFailures() method? I was earlier using Transport client and used the following code to return failures, how do I do the same using JEST client? ...

generate a java bean from a JSON file with jackson

I am working with javaFX, I need to generate dynamically java beans from a JSON file, so I want that my jackson parser the JSON file and transform it to a java bean with its attributs and getters &...

Support HTTP/1.1 and HTTP/2 with a JAX-RS client

I want to implement a JAX-RS client that support HTTP/1.1 and HTTP/2 for a JAX-RS client. The idea is to use HTTP/2 if the server supports ALPN with HTTP/2 and uses HTTP/1.1 if the server does not ...

Is there another way to do this ? I'm new to Java programming [on hold]

I wanted to know if there is another way to do this code. It is a program that displays a student's information such as; Name, Student ID, and Course. It also displays the student's exam marks and ...

Words before and after particular index position? [on hold]

I have string: "Much was I disappointed upon learning that the little packet for Nantucket had already sailed." And I need 5 words before and 5 words after the word "little". How am I going to ...

How to map a property in a class B that is a member of mapped class A?

When I submit a form I get an error: Unrecognized field "recurrence" (class CpAutoNewTestRequest), not marked as ignorable The class that is correlated with the form has a variable: private ...

Gson with RuntimeTypeAdapterFactory and GraphAdapterBuilder

It seems that Gson can't handle POJO's that has recursive reference, and can be of some sub type that is determined at runtime, i'm using GraphAdapterBuilder to handle recursion, and ...

Lnked list implementation [on hold]

I am very new in programming. Could anyone can help me below question? Thanks in advance. This is questions regarding linked list implementation by using java. Delete the first node encountered which ...

Ternary assignment without “else” expression

Is it possible to use a shorthand for ternary expressions of the type boolean x = false; // ... code ... a = x ? b : a; // Assigning a to a is pointless a += x ? 1 : 0; // Adding 0 to a is ...

compare two hashtable values and put results into an arraylist

I'm a little stuck with the way I want to compare and collect data from hash tables that I am creating. The code is a little messy as I am now getting a little confused on where to go next, I ...

Filter by string size in realm - Android

I want to do a query in Realm but filtering from a field's length. Something like this: Realm.getDefaultInstance() .where(Person.class) .greaterThan("name.length", 10) ....

How to store a map's (eg: HashMap<Character, Integer>map) integer value into an int array[]?

Currently it is storing a single value to all indexes of the array and stores the last one at the end. I want to store all of the values of the map into an int array[]. I am tying something like: ...

Deploying Javafx application with javafxpackager

I am following this tutorial to deploy an javafx Application. I am trying to run the command makeAll but I get this error: C:\Users\Documents\workspace\svg-viewer\src\main\java\com\svgviewerlibrary\...

Why won't endsWith() work with the || operator? [duplicate]

So I tried String x = "Katya@gmail.com" // <--- it's .com if (!x.trim().toUpperCase().endsWith(".COM")) { System.out.println("Your E-mail is missing a \".com\""); } else { System.out....

I have array of map data and I want to send to spring controller using angularjs

I have array data and I want to send to spring controller and iterate it. So, please help me. My code is var menuName = []; var menuText = 'developer'; var reportList = 'java, .net, android'; ...

Https connection using PEM file in java

I have a .PEM file which has both private and public certs. When I use the .pem file to connect via CURL I get the response from the server without any issues. Can anyone please guide me how can I use ...
Translating... 0%