Questions tagged [java]
Java is a high-level programming language. Use this tag when you're having problems using or understanding the language itself. This tag is rarely used alone and is most often used in conjunction with [spring], [spring-boot], [jakarta-ee], [android], [javafx], [hadoop], [gradle] and [maven].
1,769,199
questions
0
votes
0answers
3 views
cant recognize the characters in an array, says “error cannot find symbol”
I am trying to get a program to pick an element at random from an array, but I cant initialize the array. every time I run it it points at all of the elements says it doesn't recognize them.
public ...
0
votes
0answers
5 views
GraphQL java.lang.NoSuchMethodError: 'void graphql.ExecutionInput
Good afternoon faced with such a problem. Played with GraphQL. I made a test example and decided to move it to the main project. I don't even know how to describe this error and why it might pop up.
...
1
vote
1answer
7 views
How to use a HashMap returned from a method
Here I have a program which creates a HashMap within a method
import java.util.HashMap;
class Evan {
public HashMap<String,Double> abilities_get() {
HashMap<String,Double> ...
0
votes
0answers
6 views
The cards do not rotate correctly in my video game made in java (swing)
private class Listener implements ActionListener, MouseListener {
@Override
public void mousePressed(MouseEvent eventClick) {
// Recovery Card from JLabel //
...
0
votes
0answers
6 views
Is there an alternative to \b and/or negative lookahead for JFLEX?
I am building a Scanner and can't seem to find a way to identify operators like "if" or "else" using JFlex & Regex. Since JFlex doesn't fully conform I can't use word-boundary ...
0
votes
0answers
4 views
how to fetch nested element from xml using Jaxb2Marshaller
I am working on parsing a very large xml file ( > 2gb) the information is arranged in following manner.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
&...
-4
votes
1answer
23 views
Exception handling to detect input String vs. Integer [duplicate]
I need to write code where the program fails and throws an exception if the second input on a line is a String rather than an Integer. I am confused as to how to compare if the input is a string or an ...
0
votes
1answer
13 views
Java: Easier way to implement delay into a chat bot response system?
I'm trying to get just a couple seconds of delay between user input and bot output; this is what I've got currently.
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import ...
-1
votes
0answers
11 views
Attach classes Observer design pattern [closed]
Hello I was doing this project, but I haven't been able to complete it. I am trying to build an analog clock using the Observer design pattern. My question is: how do I attach the analog clock to the ...
0
votes
0answers
4 views
canvas2Draw - how to connect view class to the canvas2
full code I'm new in android studio and I'm having problem with drawing.
Upon execution it does not work
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle ...
0
votes
0answers
7 views
Android, Wrapping RecyclerView LayoutManager, RTL, Bottom-To-Top
I have a RecyclerView which uses a LayoutManager to lay-out data like this...
[...][5][4][3][2][1]
But I want to make it do this...
[9][8][7][6]
[5][4][3][2][1]
How can I?
I have attempted to use ...
0
votes
0answers
7 views
Multiple childs not working in firebase database in android studio
I have an e commerce app that should put the products he ordered in the firebase database when the user clicks the checkout button.I added code for that:
button.setOnClickListener(new View....
1
vote
0answers
13 views
Passing value from Adapter to Fragment
The application has a BottomNavigationView on the MainActivity which deals with the navigation between Fragments. One of the Fragments has a RecyclerView in it and the items of the RecyclerView have a ...
-5
votes
0answers
30 views
How to take in infinite inputs
I need the user to be able to put in as many scores(inputs) as they can into the console for my code. What code do i add and where in this code. I have been told I need a trailer value and a while ...
1
vote
1answer
13 views
How to use Liquibase with spring-boot JPA and Maven to manage migrations from JPA entities
I've been trying to use liquidbase to manage migrations on a spring JPA project in a similar fashion as python/Django does with makemigrations. Liquidbase documentation is extremely confusing and I've ...
-2
votes
1answer
23 views
Console Java - How to incrementaly add a number at the end of an url an post it? [closed]
I'm trying to do a post request + id(variable) incremental at the end for my client to check if we can mass validate an item, right now we have to do it manually which is a pain in the ass.
I'm trying ...
0
votes
1answer
27 views
Java - Generic, Factory Class
Here is a Java code structure:
public interface MyBaby<T> {...}
public class A implements MyBaby<Foo> {...}
public class B implements MyBaby<Boo> {...}
public Class Foo {...}
...
-3
votes
0answers
17 views
How can I make progress in SeekBar? [closed]
I want to make the seekbar in this picture. It will be vertical and with 50 steps. So 0,50,100,150 ... etc. How can I do that?
<com.xw.repo.BubbleSeekBar
android:layout_width="match_parent&...
0
votes
0answers
9 views
How do I confirm if persistence.xml is visible to a deployed web-app
I've deployed a Java web application on Heroku, which built successfully, I get a 500 error, which I don't get locally: Constructor threw exception; nested exception is javax.persistence....
0
votes
0answers
7 views
Google Dataproc API (through Java) does not submit Job to cluster
I was trying to get this section of code to submit a Hadoop job request based on this code sample:
import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.dataproc.v1.Job;
...
0
votes
0answers
8 views
Trouble using PathMatchingResourcePatternResolver to get src/main/resources in WAR file
I'm using Spring's PathMatchingResourcePatternResolver to attempt to get a list of .jmx files (JMeter tests) that are currently in my src/main/resources directory. This will be hosted as a WAR file on ...
0
votes
0answers
4 views
How to go from TabLayout Fragments to WebView Fragment by clicking images?
I am developing an app. In my app I have bottom navigation bar. In the bottom navigation bar I have only one button called Home which is inside HomeFragment. In my homefragment I have 4 images. ...
2
votes
1answer
40 views
Why can't Kotlin infer the type for this HashMap with a nullable value type?
When I run this code, I get a Type mismatch: inferred type is kotlin.collections.HashMap<String, Int> /* = java.util.HashMap<String, Int> */ but kotlin.collections.HashMap<String, Any?&...
0
votes
0answers
12 views
not able to download tomcat8 zip file via URL getting error Exception in thread “main” java.net.UnknownHostException: downloads.apache.org
im trying to download tomcat apache 7 zip from URL but getting error while doing the download.
but same method able to download other zip files via url.
code below:
FileOutputStream tomcat = new ...
-4
votes
0answers
17 views
Sorting Through Arrays with Numbers [duplicate]
How do you sort arrays from decreasing numbers to increasing? Also is there a way to sort an array by alphabetical order.
0
votes
0answers
20 views
Angular not displaying data received from http response
I have a Service type script class as follows:
export class HomeApiService{
apiURL = 'http://localhost:8080/api';
constructor(private http: HttpClient) {}
getProfileData():Observable<...
0
votes
0answers
19 views
Android doesn't display any image that exist on the internal storage
I am trying to access the images on android's internal storage but it doesn't shows any image. Images exists, but doesn't display it. It displays the external storage images only. An intent was passed ...
0
votes
1answer
13 views
Spring batch insert not inserting data into DB
I am new to spring and i am trying to batch insert into the databse but for some reason it is not inserting anything. Can someone please tell me what am i doing wrong.
Controller
public class ...
1
vote
0answers
24 views
Sort out the simple cycles from a list of all cycles in a undirected graph
I've created an undirected graph and extracted all the possible cycles inside it. I want just the simple cycles because I'm creating polygons from them. The problem is that I don't find an algorithm ...
0
votes
1answer
11 views
Spring boot starter parent version update
my current spring boot project has spring boot starter parent dependency pom file with version as 1.5.release. Is it possible to upgrade to version 2.0. If so, how can we achieve this?
0
votes
0answers
10 views
Type 'JavaCompile' property 'options.compilerArgumentProviders.apt$0.name' is missing an input or output annotation. error after upgrading to Gradle 7
After upgrading to Gradle 7.0 and making a build, I'm getting following failure:
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Some problems were found ...
0
votes
1answer
11 views
after updating the andriod studio i have the red lines everyWhere in my mainActivity file in andriod studio, what is the problem?
enter image description here
this is the picture which I attached please help me regarding this issue what am I suppose to do to solve this problem, it was okay before updating android studio after ...
0
votes
0answers
11 views
IntelliJ not building runnable JAR file correctly. Getting 'Could not find or load main class' when running
I have created a dummy project in IntelliJ, exported it as a runnable JAR, and ran it as a JAR just fine. The artifact properties are shown below.
However, when I try the same exact steps for ...
-1
votes
2answers
22 views
How can I convert Calendar value to String in android studio?
I have Calendar value which is from Date Picker and I want to convert this value to String format "yyyy-MM-dd"
This is my Date Picker code. I save the selected values to startYear, ...
0
votes
0answers
30 views
JDK won't change in Ubuntu 18.04
After following the advice to update versions in my Eclipse IDE, it gets worse and my editor is inaccessible now and I simply cannot work anymore:
No editor descriptor for id org.python.pydev.editor....
0
votes
0answers
18 views
Iterate through elements and retrieve text values
I have a small scraping program, that decides how many times to loop correctly
I have three values i want extracted. "// GET THREE VALUES"
I want to put a counter on them , so each loop will ...
1
vote
1answer
17 views
How to add a badge above a button?
In my MainActivity class, I have this button:
<Button
android:id="@+id/target"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
...
0
votes
0answers
7 views
Java comparator implementation response meaning [duplicate]
I'm trying to implement a method to compare 2 objects based on one of their property.
private int compareFooObjects(FooObject fooObject1, FooObject fooObject2) {
if (fooObject2.getBar() != ...
0
votes
0answers
7 views
SLF4J with Logback: NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
I'm trying to implement a RollingFile Logger using SLF4J and Logback in particular, but I'm stuck with an exception, that I can't resolve. Here it is:
Exception in thread "main" java.lang....
-1
votes
1answer
14 views
Remove “ActiveMQ.Advisory.Producer.x” prefix
Problem:
Somehow producer is sending event to "ActiveMQ.Advisory.Producer.Queue.Queue" instead of "Queue"
Active-MQ admin console in Topics section Screenshot with producer-queue:...
0
votes
0answers
13 views
How to remove \n in SQL queries in IntelliJ?
I am trying to pass a SQL query in my test automation framework. When I paste the query in IntelliJ, it is automatically adding \n and + to the existing query as below. How do I fix this in InelliJ?
...
0
votes
0answers
13 views
How to asign value to local variable from Java AWT actionListener
I would like to make a String return type method which will return specific value when the button is pressed, I have come up with the code below which unfortunately does not work. Could anyone suggest ...
0
votes
2answers
25 views
Nested streams to a Map Java 11
Let's say you have an interface, a couple of implementation classes and an Enum like this:
Interface:
public interface Employee {
// No two employees will have same favorite hobbies
List<...
0
votes
0answers
7 views
Read file from android storage in Appium
I'm trying to read file from sd card using following command:
byte[] fileBase64 = driver.pullFile("/sdcard/image.jpg");
But I'm getting following error:
org.openqa.selenium....
0
votes
0answers
11 views
Is possible to loop a readUTF to read multiple unknown server lines?
I'm wondering if there is a way to loop a .readUTF from a code like this:
public void startClient() throws IOException {
DataInputStream input = new DataInputStream(socket.getInputStream());
...
0
votes
0answers
8 views
How can I dump XML body of XWPFDocument?
This seems like it should be easy, but I can't find the answer anywhere.
Using Java 8, and Apache POI and Apache POI-OOXML 4.1.2, we are converting documents from an XML-based derivative of EPUB3 into ...
0
votes
1answer
5 views
SUTime Python problem with java heap space
I recently installed sutime for python and followed instructions from this link: https://github.com/FraBle/python-sutime , and after running the code below, the "Could not load JVM: java.lang....
0
votes
0answers
11 views
How to use Cucumber.class and Parameterized.class over the same Runner Class
I have a cucumber runner class. which I have to execute multiple times in one go depending upon the parameter I have provided.
Suppose provided parameter is A, B.
So Runner will execute 2 times one ...
0
votes
0answers
13 views
Java Swing FrontEnd with C++ Backend using Sockets to send/receive Strings of any length
I got that application to a college class, where I need to do a Program in Java and it's interface. In the first stage of the class, we did the first part of the app in C++, and now, the teacher wants ...
1
vote
1answer
14 views
Convert a bson Document to byte array java
Have a use case where I need to compress and store a org.bson.Document into cache. I am using zstd compression which expects a byte array. Not able to find a way to convert Document into byte array.