Questions tagged [java]

Java (not to be confused with JavaScript, JScript or JS) is a general-purpose, platform-independent, statically typed, object-oriented programming language designed to be used in conjunction with the Java Virtual Machine (JVM). "Java platform" is the name for a computing system that has installed tools for developing and running Java programs. Use this tag for questions referring to the Java programming language or Java platform tools.

Filter by
Sorted by
Tagged with
0
votes
0answers
7 views

App crashes when I try add data or view data

When I try add data or view data my app crashes instead of adding to SQLiteDatabase MainActivity: public class MainActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener , ...
0
votes
0answers
3 views

OSGI kafka stream application throws LogAndFailExceptionHandler

I am not able to run my simple Kafka streams application in Apache Felix framework, running it as a normal jar works fine. It throws the following exception: ERROR: bundle com.openet.odf.streamer-...
0
votes
1answer
8 views

Overload constructors of subclass

So i have an abstract class: public abstract class Superclass { private final boolean isTrue; private final int number1; private final int number2; private final int number3; ...
0
votes
0answers
6 views

How to connect both website and android application into one firebase database

I am having trouble on how will I access all the information needed because I am creating an android application and a website having the same data in it. I want to see that the data I enter in the ...
0
votes
0answers
6 views

Attempting Spring Boot form validation with thymeleaf, but getting an error that I can't figure out

I have a demo web application that I'm attempting to add error checking on the form to with error messages that will display next the the related inputs. However, after implementing a method that I ...
0
votes
0answers
7 views

Whats the difference between package and groupId in maven

I understand the terms, groupId, artifactId and version. While reading about package, I can see it is The name of your root package. The default is the groupId you entered before.. In that case, what ...
0
votes
0answers
6 views

How to Store a multiple values( during run time) in a map and getting a single value again

Iterator searchGetResponseIterator = searchGetResponse.entrySet().iterator(); Object obj = null; Object dataPicker = null; while(searchGetResponseIterator.hasNext())...
0
votes
0answers
11 views

Balanced vs Unbalanced Binary Tree - Clarification Needed

I am in need of some clarification, this may be a really stupid question and I have done research but cannot find a clear answer to my question. My question is, What are some property differences ...
-2
votes
0answers
15 views

List all common elements between n arrays and choose on specific conditions [closed]

Let's say we have a problem like below: Luci is a working as a secretary for Stack-overflow club. She is assigned to prepare gifts for events which will be held in the next month. There will be a ...
0
votes
0answers
6 views

Spark application uses only 1 executor after run flatMap function

I have an application that calculates the level of product interest using apache-spark. I use groupBy to group products by category, then use flatMap to combine data to save into mongodb. However, ...
0
votes
0answers
6 views

Using Nginx get “OTS parsing error: incorrect file size in WOFF header”

description In the beginning, i use ip:port visit my portal website, the font can display, then i start use nginx to listen 80 port and redirect to origin port, get some odd warnning, and font no ...
0
votes
0answers
24 views

Why do some printf statements not move the number to the right? Examples shown

System.out.printf("Number:%5.3f\n",point); System.out.printf("Number:%8.3f\n",point); System.out.printf("Number:%5.6f\n",point); My question is why do the 1st and 3rd printf statements not ...
0
votes
0answers
10 views

JFrame graphics doesn't draw anything

I am trying to draw a rectangle to test out my game engine, but nothing is drawn on the JFrame, I can't seem to figure out anything that has been causing this. I tried using extending the JPanel and a ...
0
votes
0answers
5 views

JPA NamedQuery for OneToMany Relation

I am trying to create a named-query in my orm.xml but I am not sure how it works with the collection. I have created a query in postgresql which gives me the correct output. But I am not able to ...
0
votes
0answers
8 views

Spring Data JPA circular reference in getting SesionFactory

I'm trying to start a Spring Project, and I've made all the configurations, however, whenever I try to start it, I get the following error message: Error creating bean with name 'getSessionFactory': ...
0
votes
0answers
5 views

How can I show the values of Nodes with specific id and tag name and under specific parent node in Java, XML file?

I want to show the values of nodes in Java from XML file with name “x2” and id=“a1” that are direct children of nodes with the name “x1”, here is my code which I tried, but I am not able to complete. ...
0
votes
0answers
13 views

JavaFX table is not displaying data

I am following this tutorial to write a JavaFX code to populate and display records in a table. The records can be multiple and the records are the objects of the LibraryMember class (provided below), ...
0
votes
0answers
10 views

Java's BlockingQueue Take Policy

In a multi threaded environment, what is the policy regarding the take() method (removing an element) for the various implementations of a BlockingQueue in Java (like LinkedBlockingQueue)? Is it ...
0
votes
2answers
14 views

How Do I convert a String into CSV File using CSVWriter

I have a String that looks like this: Year;Make;Model;Params 1997;Ford;E350;[2.35, 1.11] 2000;Mercury;Cougar;[2.38 3.23] I wonder how can I convert this into a CSV file using semi-colon as the ...
0
votes
1answer
28 views

why java method return same result?

i have problem with my program << this program take information for 3 student name and id and marks in 5 course then return information with marks avrage my program is work good but it return ...
0
votes
2answers
30 views

How to init an object in a JUnit test?

I am trying to do a JUnit test to test a Controller. My Controller consists of: @Autowired private OrderManager orderManager; @RequestMapping(value = "/getOrderList", method = ...
0
votes
2answers
21 views

using simpledateformat to parse string date with 6 digit of milliseconds

I am trying to parse String date to a particular date format, but when I used options available from SimpleDateFormat I always get different result. This is the string i am trying to parse: Sting ...
-2
votes
1answer
22 views

What do I need to do for this code to not get error ';' expected for line “for(int i=0; i<numElements)” [closed]

Gives error ';' expected for line 21. Help me figure out what I'm supposed to do to make the code compile please. import java.io.*; public class ReadBinaryFiles{ public static void main(String[] ...
-2
votes
0answers
11 views

Controlling JFrame open and close [duplicate]

I have a GUI class that instantiates several other objects, and when you click on JButtons on the GUI, those objects' methods are called. One of those objects is a slideshow, which displays on its own ...
0
votes
1answer
24 views

Is Java's HttpServer asynchronous?

I would like to implement a lightweight HttpServer that can handle both GET and POST requests into a Bukkit plugin. The current setup I have for my tiny web server creates an object extending Thread. ...
0
votes
1answer
11 views

I am trying to implement and 'undo' JButton on a simple bank system that will undo the last action performed

I have the rest of the code running but I'm not sure what to do in the ActionListener for the Undo Button. I only have this as far as the action listener goes private class UndoButtonHandler ...
0
votes
0answers
7 views

Flow id in android (like a thread id)

I have many work flow functions. For example: Flow 1: object1.A() -> object2.B() -> object3.C(); Flow 2: object1.X() -> object2.Y() -> object3.C(); I would like to check that, if C() is call from flow ...
-1
votes
0answers
17 views

why does int i tell me that it cannot be converted to int or that they are incompatible types?

private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) { int i = metodos.guardar(txtNombre.getText(), txtApellidos.getText(), ...
0
votes
0answers
14 views

Is there another way to instantiate a concrete instance of an abstract class inside a list during spring databind?

Given the following classes: @Data @MappedSuperclass @Accessors(chain = true) public abstract class EntidadeDeDominio { public EntidadeDeDominio() { type = getClass().getSimpleName(); ...
-1
votes
1answer
23 views

Cant access method in main class

I'm new into java programming, so I'm now struggling with exceptions. So I would like to hear some advice from experienced users. My main question is why can't I user method "validate" in UserDemo ...
0
votes
0answers
18 views

Is immediately waiting for a thread to finish the same thing as locking the main thread? Android

So I understand that we use new threads for potentially expensive actions, as to not lock the UI thread. But my question is, for the following the code, since I'm waiting for the thread to finish ...
1
vote
0answers
8 views

How can I pass variable instead table name in @Query annotation in Spring boot?

I want to pass variable instead table name using @Query annotation but doesn't work.. @Modifying @Query(value="insert into :table (name,password) values (:name,:password)",nativeQuery=true) void ...
0
votes
0answers
13 views

I made it so that the player is facing the mouse direction, but because of that there is a problem

So basically I wanted to create zombies to interact with them later on, but when I drew them I noticed that all of them are turning to the same direction as the player (to mouse) it happened with ...
-3
votes
0answers
22 views

Made a mistake in previous question, questions are the same but launcher code is different

Repositories don't get initialised when application is started The question in the link is what I am asking but I put the wrong game launcher code. It's actually this: public class ...
0
votes
0answers
11 views

Get the current backoff value when using Spring RetryTemplate

So I've been experimenting with Spring's Retry Template. Everything is working as expected. One thing I would like however is the ability to extract or log the current backoff time that's being used....
1
vote
0answers
28 views

How can I stop these cars from hitting each other?

I'm working on a simple traffic simulation for practice, as I'm fairly new to programming. I've gotten all I want to work so far, but when a car stops at a red light, the cars behind it just run into ...
-3
votes
0answers
11 views

Having trouble understanding how to comprehend a “line” assignment [closed]

I have an assignment where I have to make an overloaded class "line" with methods such as intersect, equals, and is parallel all corresponding to another instance of a line. I am not really sure what ...
-3
votes
0answers
18 views

Writing code to change a string value in an Array List

The function H2 should take an ArrayList of Strings as a parameter, and change the 4th value to the String “Seventy Three”. >Following this instruction this is the code I've came up with so far, but ...
0
votes
0answers
10 views

How can I access Objects within a void method while unit testing?

I am unit testing a Spring Boot service method. I have a void method with no args. It queries a db and gets a List. I can mock and assert on that. Then it runs through the list and changes object ...
0
votes
1answer
22 views

converting aplhanumberic string to double

I am trying to convert a alphanumberic string to double and wondering if there is any simple method like atoi is available for doubel in java? sample string "16.78%" => 16.78 Tried Double....
0
votes
1answer
22 views

Why my menu is not working as it should? Scanner not working as well

package hangman; import java.util.ArrayList; import java.util.Scanner; public class Hangman { public static void main(String[] args) { int maxGuess = 5; // chances or life String ...
0
votes
0answers
12 views

IntelliJ Java groovy missing library?

So I have been using IntelliJ for a while now still don't know my way around but so far from what I know is good! Somehow one day I opened it to start on a new project (I use java btw) the groovy ...
0
votes
0answers
6 views

Does JPA ORM.xml has an Xml tag that match @DiscriminatorFormula annotation?

I have an abstract class and a subclass to the previous. public abstract class F {} public class S extends F { private String type; } I am trying to control the value that will be store in ...
0
votes
0answers
8 views

Java assignment to use Dijkstras search method, breath-first and depth first

Hello StackOverflow community, need your help. I have a final for my java class and its asking for: Generate a graph with 100,000 nodes, where each node randomly has between 1 and 5 connections to ...
0
votes
0answers
17 views

Delete entire topic from State Store

I'm trying to delete an entire topic and a single record in a topic from the stateStore (Not at the same time) based on the key provided. So if key that I passed in equals a key in the stream, turn ...
-3
votes
0answers
35 views

Create Java Regex Pattern to match string inside XML [duplicate]

I'm trying to create regex pattern to match String inside XML text. For example: String to match: A PLP não será fechada XML Text: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/...
-4
votes
0answers
11 views

How do i create an instance of an object with various parameters in a fragment [closed]

Am trying to create an object, the class constructor contains five parameters and am trying to create an object of this class in my fragment class... pls how do i go about it
-2
votes
1answer
31 views

Why aren't the return statements printing?

I'm coding a program that lets you alter and view the statistics of a jar of cookies. The user can put in a type of cookie and the maximum cookies in the canister into the constructor. If the user ...
0
votes
0answers
4 views

AEM Sling Resource Resolver Mapping Methods

I have been poking around the Internet for some time looking for more information on configuring Sling Resource Resolver mappings. From what I found online and my experience there are currently two ...
-6
votes
0answers
15 views

What is true among the following options in java [closed]

Which of the following is true? Non-static member classes must have either default or public accessibility 2 . All nested classes can declare static member classes Methods in all nested classes can ...