Newest java Questions

Q&A for professional and enthusiast programmers

Changing jframe attributes without actionperformed?

I'm trying to make a hotkey program using jnativehook however I'm unable to change the color of say a button when I press a key (outside focus). The key press and everything works fine but I'm ...

Else If's logical equivalence

Is there ever a case where: if (condition) { statement } else { if (condition2) { statement } else { statement } } Is not equivalent to: if (condition) { ...

Replace every nth character with “-” in java without regex

I am trying to replace every nth character in a string with some special character for e.g "-" so based on value of input (int n and String str), I want to replace all chars at n ( like 2, 4, 6) by ...

ZipInputStream getNextEntry() Returns Null after Android 6.x update

I had working unzip code that uses ZipInputStream to unzip a large zip file from an InputStream. I have tested with some sample ZIP files on Android 5.1.1. I recently updated my development Galaxy ...

Determine JSON path when a field contain dots (in the format of session.content)

Below is a portion of the response I am getting via REST API call. I am trying to use the response, parse using Java but "session.content" is causing a problem. "fields.'[session.content]'" shows up ...

JavaFX: SplitPane changes divider position on resize if there are items inside

I have the following code: public class JavaFxApplication2 extends Application { @Override public void start(Stage stage) throws Exception { SplitPane splitPane=new SplitPane(); ...

How to show Progress Dialog while Content Provider updating the database?

My Application uses a Content Provider to provide data from a pre-populated Database using a DatabaseHelper Class. This DatabseHelper class copies the database from my Application Assets folder to ...

Converting String to Number in Java

How can i convert a string to a abstract number, provided string is any valid number in java (say int, long, double etc). I will not know the type of number in the string, so i can't use specific ...

JAVA Client State Management for Webhooks

I'm working on a Chatbot for Facebook Messenger. The API has no option to define a Payload which I get when a user is answering my message. Take for example this scenario: User: "I want Shoes" ...

Counting program time error in java [duplicate]

I'm assigned to see how much time it takes for bubble sort for the numbers. It took 18 ms for text file 2 which has around 100,000,000 numbers but it took 2 ms with more loading time for text file 3 ...

Android 6.0+: how to catch click on 'accept' or 'refused' button of geolocation authorization alert? [duplicate]

I use the following code to know if the user granted the geolocation permission and display an alert if it is not the case: if (ContextCompat.checkSelfPermission(this, android.Manifest.permission....

Build constraint violation with more than one property node programmatically

I'm writing a method to build programmatically a constraint violation, so this method receives an array of String and add all of these strings as a property node to build a constraint violation. To do ...

If user presses enter (without anything else) how can I print out the line (“please give a valid command”)?

I have a program in java where the user have to give command. However if he presses enter without anything else the program stops and he gets this: "Exception in thread "main" java.util....

using vba to Setting calculated values to bookmarks in a Word Document

Take a look at this vba code; this vba code currently copies a value from cell E40 and paste it at its specific bookmark location "fundedRatio" in a word template. What i want to do is access the ...

Can't connect to Bigtable from a Spring Boot application

I have a standalone application that works fine with Bigtable when creating a connection like this: Connection connection = BigtableConfiguration.connect(PROJECT_ID, INSTANCE_ID) and using the ...

What is the use of inheritance if the same thing can be done by creating package?

My question is about advantages of inheritance in java. All the properties of a class can be accessed by another class if both the classes are in same package, then what is special in Inheritance? ...

Assistance writing a recursive function that sums a list of arrays in Java

I'm attempting to write a recursive program that adds up the sum of a list of arrays. It requires use of a helper function, as reflected below. I am failing to see what I am doing wrong, but I think ...

Java android onCreate always call

I have a probleme when I lock my phone and unlock in one Activity always call onCreate . Maybe someone can help me ? This is my onCreate , maybe I do something wrong , which call a onCreate. On create ...

how to get number of strings not containing specific pattern

the actual question is- 1. A decent-string is a string made of 1’s or 2’s or 3’s. Find the number of decent strings of length 30 which do not have pattern ‘123’ in that string? integer or long ...

Reverse Integer

Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 I was trying to use the code below to solve the integer reverse problem. But when I convert the int to a ...

Spring boot with DB Connection to a Non database project

I have a project with Spring boot 1.4.1 which connects to an Oracle database, i want to generate another project with no connection to database, I removed the pom dependencies and changed the Starter ...

Custom adapter's asynchronous behaviour

I have created my own custom adapter class in my android app and I am calling it from one of my activity. I am adding some elements to the view from the adapter class and I need to access those ...

How to keep using SSDP to search for devices on local network on Android?

I'm developing an app that, at startup, uses SSDP to connect to a server and retrieve it's IP Address. The SSDP class was not developed by me so I'm open to any refactoring suggestions in there as ...

Get random numbers without repetition in Java. The one I made is too slow

import java.util.Random; import java.util.ArrayList; public class RandomExample { private ArrayList<Integer> occurredNum = new ArrayList<Integer>(); private Random r = new Random()...

Get Text using Coorindates(X,Y) Using Webdriver

I working on an desktop application using winium driver which is similar to web driver java. But the application which i am currently working doesn't support any locators like eg: Class names, id,CSS ...

How do I enable that a command line argument is optional in Java?

This is my command line: java MyProgram arg1 arg2 I want arg2 to be optional. If arg2 is not given, it will be replaced for a default value. How do I do this?

Inconvertable types :can't cast Object to int

my program is int totalDuration=(int)session.createCriteria(Track.class).setProjection(Projections.avg("duration")).uniqueResult(); but i have error . error is : Inconvertible types; cannot cast '...

libGDX AssetManager not loading a texture

borderTexture = new Texture(Gdx.files.internal("images\\sprites\\levelSelect\\border.png")); //^this works and draws nicely man = new AssetManager(); man.load("images\\sprites\\levelSelect\...

Implement dymo label printing in java

I am trying to implement code from another question, but I am having a hard time figuring out what to put in my actionEvent handler to call the code. Printing in Java to Label Printer is the quest I ...

Selenium automation with Java

I am doing a basic selenium test with Java using Eclipse. I am following this tutorial. https://www.youtube.com/watch?v=2SzdhH8xAX4 But I get the error when trying to run the code. And here is this ...

Java | Checking Bounds of Matrix

I'm attempting to do a simple check to make sure the row and column supplied by the client is in bounds of the matrix's array. However I keep getting a Failed: junit.framework.AssertionFailedError ...

Selenium, select value from listbox without using select in Java

I am new to selenium, was just practicing for various sites. I am not able to select value from dropdown, tried Select dropdown_month = new Select( driver.findElement(By.xpath(".//*[@id='...

Most efficient way to scan all possible permutation using Iterators on HashMaps

I want to find the most efficient way to scan all possible permutation using Iterator with HashMaps. To code I wrote is the following: Iterator<Entry<LinkedList<String>, Record>> ...

DocumentFilter in java and ctrl+v is not working

When I'm trying to use of this DocumentFilter the ctrl+v and ctrl+c is not working. public class stringLengthTrim extends DocumentFilter { private int limit; public stringLengthTrim(int limit) { ...

how to read the values of Arraylist from Map in java

I am not able to read the values of Arraylist from MAP from the below code please suggest what should do. @Override protected void onPostExecute(Map<String,List<CommentModel>> ...

how to change widget id programmatically on android studio

how to change widget id programmatically? example i wanted to change XML code <TextView android:id="@+id/Title" android:layout_width="210dp" android:layout_height="20dp" android:...

Parse XML using parsedata() loses login in session in Andriod Studio

I am having an issue with the parseData() java function in android studio. I need to use it several times in one activity. The first time it loads, it grabs information from a url and displays the ...

Function of Dollar Sign in Formatting Strings [duplicate]

I came across a solution online on how to right-pad integers with zeros and I have a question on how exactly the printf works. public static String formatString(int i, int t, String vs) { return ...

Best Opensource Business Process flow [on hold]

I have a project where users need to be able to draw a business process interactively and upload that into the system and be able to run the flow based on the new active Business process flow. What ...

Android: SAML authentication in a webview

I'm trying to integrate SSO into my Android app using a webview. I'm loading a webview with the URL of the identity provider which gives me a login screen. Upon entering login credentials I can ...

Pass oracle object type to java stored procedure

Is is possible to pass oracle object type to java stored procedure. Here's what i have so far. Java stored procedure: create or replace and compile java source named Example as import java.sql....

Spring Data + JPA > New entries of “mappedBy” property are not fetched from DB after SQL INSERT

Hej. I think I am experiencing some odd behaviour with Spring Data, JPA and the alike. I wrote a flyway migration script that inserts new data into a table cash_entry_note. Which is related to an ...

How to create group chat in android using PHP Laravel

how do i use php socket.io or https://github.com/walkor/phpsocket.io creating group chat for android application , Please help me

How do I make a .jar file with a .jar file?

I'm creating a program that makes "candy".jars and I need to make this "candy".jar with a creator.jar file. The idea is you run the creator.jar file and you can adjust settings inside of it in order ...

MyBatis Spring DYNAMIC number of multiple databases Java configuration

This is fairly straight forward with a simple Spring DAO approach. However, using MyBatis, is there a way to setup multiple potential datasources? The best approach I can think of is to use an ...

Kafka Connect S3 sink throws IllegalArgumentException when loading Avro

I'm using qubole's S3 sink to load Avro data into S3 in Parquet format. In my Java application I create a producer Properties props = new Properties(); props.put("bootstrap.servers", KafkaHelper....

Getting weblogic.management.NoAccessRuntimeException on creating webservice of java class

I have created a class which will create weblogic users using jmx data control. The code to create weblogic user is: @WebMethod public String createWeblogicUser(@WebParam(name = "arg0") String ...

Should I implement an Array into this? [on hold]

I need to make a program that stores and analyses game statistics for 6 players and provide the user with the high ,lows and averages. I am having trouble with displaying the name of the person with ...

How to refer to context menu item outside of OnCreateOptionsMenu?

I am trying to disable the "purchase" item in my context menu once the purchase is made. I also want to enable the "user gallery" item when the purchase is made. My code is: IabHelper....

How to execute JAVA code from JS in JSP

I'm working with Java Web at Netbeans 8.1, actually I'm working with AJAX in the proyect and this issue stops me: This is my JS function in JSP: $("#formAddFundo").submit(function(event) { /* stop ...
Translating... 0%