Questions tagged [java]

Java is a high-level object-oriented programming language. Use this tag when you're having problems using or understanding the language itself. This tag is frequently used alongside other tags for libraries and/or frameworks used by Java developers.

java
Filter by
Sorted by
Tagged with
0 votes
1 answer
2k views

How to custom objects from TestNG Dataprovider

I have the below DataProvider in TestNG. It has List of custom Objects called DataSheet[]. I need to pass it to Test method individually but it returns as array. @DataProvider(name="accountsDetails")...
Beginner's user avatar
  • 313
0 votes
0 answers
49 views

How can I figure out why I see obfuscated methods when profiling Java code?

I've been trying to use the Java VisualVM profiler to figure out ways to make my own code more efficient, but I've noticed that a lot of the method calls I see when I try to do CPU sampling on the ...
idolos's user avatar
  • 123
1 vote
1 answer
108 views

GSON.fromJson() issue with hashmap

I'm using GSON 2.5. I have 2 Strings: String reservationRoomNightGood = "[{\"reservationRoomNightParams\":{\"date\":\"2016-06-05\",\"totalPrice\":600,\"currencyCode\":\"EUR\",\"crsRatePlanId\":0,...
Killesk's user avatar
  • 2,944
3 votes
0 answers
514 views

Spring Security: GlobalMethodSecurity not calling custom AccessDecisionManager

I seem to be having a interesting issue where the GlobalMethodSecurity wont call the correct AccessDecisionManager: I have set the AccessDecisionManager in the application-context.xml: <global-...
Toby Larone Barrett's user avatar
2 votes
1 answer
2k views

STRUTS 2 java.lang.ClassNotFoundException

I am trying a simple helloworld and I am getting the below error when I start my server: SEVERE: Exception starting filter struts2 java.lang.ClassNotFoundException: org.apache.struts2.dispatcher....
SargeOrona's user avatar
0 votes
2 answers
197 views

Java Filenotfound exception in jar file

i wrote a program, but when my friends try to execute it it throw filenotfound exception, but the file is exist, here is my code, and in the folder have lib folder, the jar file and the "csv fajlok" ...
user5555231's user avatar
8 votes
1 answer
12k views

How to serialize ObservableList

I am working on a javaFx project where we have to use ObservableList to add Listners. ObservableList includes Model of persons. But I want to store the whole ObservableList Object in a file through ...
Abdullah's user avatar
  • 135
0 votes
1 answer
110 views

Android "public String"

here is my code: public void generujCislo(int pocetCislic) { TextView generovaneCislo = (TextView)findViewById(R.id.generujCislo); Random random = new Random(); String nahodnaCislice; ...
user avatar
2 votes
3 answers
348 views

java regex can't use symbol ? and {n} together

I would like to write regex that match string with follow rules: At first and last position can be symbols a-z A-Z or 0-9 but not . or - Hole length of string 16 characters In the middle can exists ...
fidel150992's user avatar
0 votes
1 answer
187 views

Is it possible to use "Spring Boot like" Environment abstraction with normal Spring?

I try to configure my Spring application by application.properties files. The default one will be in my WEB-INF directory, but I need also the opportunity to supply --spring.config.location. ...
Michał Mielec's user avatar
3 votes
1 answer
235 views

Streaming Pattern Matching using Regex

I'd want to parse a large text file formatted in Warc version 0.9. A sample of such text is here. If you take a look at it, you'll find the whole document consists of a list of following entries. [...
frogatto's user avatar
  • 29k
0 votes
1 answer
679 views

Is it possibile to retrieve org.postgresql.util.PSQLException's cause from IllegalArgumentException inside EJB?

I have a project which uses EJB3 and when the code throws an exception related to SQL, it sends a notification to the development team. So, for example, with this code: Query q = getEntityManager()....
Chris's user avatar
  • 1,168
0 votes
4 answers
57 views

setPlayerHp() in Player cannot be applied to integer

I'm writing a Text Adventure app for my course, and I've come across this error. I have a class named Player with three variabled associated (playerPos, playerHP and playerInv[]) When I try to get or ...
Jay Roberts's user avatar
1 vote
3 answers
3k views

Java recursion sum of odd even

I have to write a java code (its not a homework ) We take a method int n and we return : If (n positive and odd )--> 1+3+5+...+n If (n positive and even) --> 2+4+6+..+n If (n negative or zero) --...
Kami H's user avatar
  • 31
0 votes
2 answers
1k views

FileInputStream example, I/O error: File not found

I'm doing example from the book "Java The Complete Reference Ninth Edition" that demonstrates FileInputStream using try-with resources. In the output I've got "I/O Error: java.io....
Eugenia Ozirna's user avatar
0 votes
1 answer
834 views

Issue with Producer Flow Control in Camel Route (Persistent Messages)

I am having issues finding the correct set of activemq configurations to ensure a consistent throughput of messages in a Apache Camel route. The current configuration is using the following tech: ...
Eric Ekong's user avatar
2 votes
0 answers
3k views

Spring Data JPA repository find method returns null collection but collection size is correct

I am using Spring Data JPA: <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa</artifactId> <version>1.7.1.RELEASE<...
Mukti's user avatar
  • 301
0 votes
3 answers
120 views

How to get substring to specific character

Have specific substring like: {"access_token":"...
Michal's user avatar
  • 573
2 votes
0 answers
905 views

notifyDataSetChanged() not working with Filter

I am trying to set up a simple search on my listView. I am setting a custom adapter : MainActivity.java // Locate the listview in listview_main.xml listview = (ListView) findViewById(R.id.listView); ...
Guitz's user avatar
  • 1,385
0 votes
2 answers
155 views

listing all the airlines from united sates mapreduce program

The below mapreduce code is written to get the following output: "Princeton Aviation Corporation" "Priority Air Charter" "Priority Air Transport" "Priority Aviation Company" ...
HARSH PARMAR's user avatar
1 vote
3 answers
693 views

for loop skipping first string in array

I currently have an issue in my script where I use a for loop to iterate through an array of elements and check for their existence in the GUI. My issue is the for loop always skips the first entry of ...
jagdpanzer's user avatar
1 vote
0 answers
91 views

spamModerationLevel in Google java api

So I'm lookign into ways to edit some of less visible setting s on a google group, in specific the one found in: Access Settings > Settings > Moderation > Spam Messages This setting is what I ...
Stephen's user avatar
  • 11
0 votes
1 answer
3k views

Spring Failed to load ApplicationContext when include @EnableWebMvc

I work on some application, and I want to include Spring MVC structure. Everything work fine, but when I include @EnableWebMvc everything crash! This is mine a spring config: @Configuration @...
Lackeeee's user avatar
  • 459
1 vote
1 answer
52 views

Is there a way to inadvertently stop the threads of an Executor?

I tried crashing the Thread of a fixed thread pool of a standard ExecutorService with this horrible code, in order to test its resilience against exceptions and errors happening inside the tasks ...
giorgiosironi's user avatar
0 votes
2 answers
306 views

Java catch exception design and performance

I want to understand something about catching exceptions. If I don't want my application to crash while an exception occurs and have no idea what exception will be thrown, then my way of handling ...
Smiled_One's user avatar
48 votes
7 answers
54k views

When does the Apache Kafka client throw a "Batch Expired" exception?

Using the Apache Kafka Java client (0.9), I'm trying to send a long series of records to the broker using the Kafka Producer class. The asynchronous send method returns immediately for a while, then ...
James Thomas's user avatar
  • 4,323
0 votes
1 answer
95 views

set updatedby only if any eniy data has changed

In my customer entity I would like to save a changedByUserId field. I only want to set this field if one of the other fields of customer has really changed. If I allways set it I force EntityManager ...
java1977's user avatar
  • 398
0 votes
4 answers
895 views

How to implement stoppable and cancellable folder synchronization in java?

I have two directory structures and need to synchronize them, i.e. copy into the target folder the files and folders from the source folder that are new or changed and delete the files and folders in ...
Sargon1's user avatar
  • 874
1 vote
1 answer
109 views

How to log CharConversionException from HttpServletRequest getParameter

From time to time i'm getting this error when calling getParameter on an HttpServletRequest: INFO: Character decoding failed. Parameter [SomeParameter] with value [SomeValue] has been ignored. Note ...
germanTHX's user avatar
2 votes
1 answer
824 views

Convert our internal userdetails implementation to Spring's User object

I am getting NoSuchMethodError when I try to convert the Boolean field. I know I can convert boolean primitive but somehow I want to make it Boolean object so that whenever needed I can set it to null ...
sjain's user avatar
  • 23.3k
0 votes
1 answer
1k views

method may produce 'java.lang.NullPointerException' [duplicate]

I am trying to add in a tabbed activity the app icon to the app bar and the answer is: method may produce 'java.lang.NullPointerException'. I have read and tried all the answers here and none of them ...
Alex Simion's user avatar
0 votes
1 answer
642 views

How to keep an actor inside the stage in libgdx?

I'm creating a game using libgdx and I'm using stage and actors for the entities inside the game. but the problem is I cant keep the actor inside the stage or the screen. when i drag the actor in the ...
ItumNgaIring's user avatar
1 vote
1 answer
133 views

OutOfMemoryError when rendering ImageButtons

I got an out of memory error and am not exactly sure how to handle it. I would appreciate any help! I think the problem lies with loading too many images, but how can I avoid that? I think I'm only ...
Conanap's user avatar
  • 165
0 votes
1 answer
437 views

Set size of java element using AWT

I am new to java. I have started learning java 1 day ago.. I am background of c++ (not very good 1 year of intermadiate exp). In java we have started Gui programming. So i would like to ask you how ...
user avatar
2 votes
1 answer
53 views

Passing a map to a function that specifies a map argument with unbounded wild cards

I am basically trying to do a check of a Map in Java. My code is as follows. private boolean isValid(Map<?,?> map) { return (null != map && map.size() > 0); } Why can't I use this ...
Jane Wayne's user avatar
  • 8,525
2 votes
1 answer
339 views

A Queue of deques in Java [duplicate]

I want to have a data structure conformed by a list of deques. So, taking advantage of the FIFO disposition of elements in a queue, I instantiated the following: Deque<String> pathQueue = new ...
Nana89's user avatar
  • 432
-1 votes
2 answers
614 views

Random number frequencies

I have created a array consisting of 6 numbers, and I randomly print the contents 100 times (to simulate rolling a dice 100 times). Now I want to show the frequencies of each number printed, which I ...
dontfartinthecar_'s user avatar
9 votes
0 answers
31k views

How to create a secured TCP connection via TLS v.1.2 in Java

I want to create commnicate between two systems via TLS v1.2. The information it contains is confidential. I want to avoid an https web service call and diectly want to perform message exchange at the ...
Argho Chatterjee's user avatar
0 votes
1 answer
63 views

Reading postgres tables in terminal with java

Iḿ trying to build an application which collect all tables in my postgres db, by java code. Process p1 = Runtime.getRuntime().exec("su - postgres -c \"psql -p 8080 -l -t | awk '! (/^ / || /^ ...
user2734182's user avatar
  • 1,835
1 vote
0 answers
477 views

expected END_OBJECT but was BEGIN_OBJECT

I'm trying to run a login in my android apk, at first it looks nice but when I try to log in or submit, a message shows up "expected END_OBJECT but was BEGIN_OBJECT" My code: private void ...
La Fortuna's user avatar
0 votes
1 answer
306 views

Incompatible Types: Cannot Cast View to CheckPreferenceBox

I'm playing in the settings someone else made for my app and I want to uncheck a CheckPreferenceBox when the user cannot properly connect to dev servers. I call my CheckPreferenceBox this way: ...
dequec64's user avatar
  • 923
0 votes
2 answers
262 views

Using Future with ExecutorService

I need to execute two tasks in parallel and wait for them to complete. Also I need the result from the second task, for that I am using Future. My question is that DO I need executor....
Zeeshan's user avatar
  • 12.2k
0 votes
2 answers
4k views

Java unhandled Exception

I'm currently developing an Android app using Android Studio and I encountered an error that I can't understand. Here's an example of my code : public class MyClass { public void method1() ...
Jejefcgb's user avatar
  • 390
0 votes
1 answer
22 views

automated buttons implementation in java

I want to have a for loop, that can implement and add a specified number of JButtons the one after the other. I was trying to implement it and this is my code so far: import java.awt.*; import java....
jakline nataly's user avatar
1 vote
2 answers
716 views

Why can't I return Object in Java linked list traversal when using recursion?

In the book, Cracking the Coding Interview (6th Edition), a problem asks me to: Implement an algorithm to find the the kth to last element of a singly linked list And later, the author claims: ...
KZcoding's user avatar
  • 1,467
3 votes
1 answer
464 views

test the web application of jsf2.2 using owasp

We are going to test a JSF 2.2 application using OWASP ZAP. But, it can not be performed well: the test can't understand how the takeover of id of javax.faces.ViewState. Is it possible to take over ...
rootman's user avatar
  • 33
2 votes
1 answer
1k views

Java Conversion table convert É to E

Is there a java function/sample of code that will help me convert some unicode characters to its readable counterpart? For example: Original converted ¿       &...
Cross2004's user avatar
  • 951
2 votes
1 answer
5k views

Do not concatenate text display with set text, use android resource instead?

@Override public View onCreateView(LayoutInflater inflater,@Nullable ViewGroup container,@Nullable Bundle savedInstanceState) { View layout=inflater.inflate(R.layout.my_fragment, container, ...
user avatar
0 votes
2 answers
447 views

What's the most common used layout in Swing?

I'm trying to figure out how to work with the layoutmanager in swing and honestly... I'm realy having a hard time. Is there a most common used layout or does it realy depends on which context you ...
Ji Joe The Man's user avatar
8 votes
3 answers
9k views

Is there a way to determine if a DateTimeFormatter is date only or time only after construction?

With Java 8's new date time library, the way to parse strings into dates is to use the DateTimeFormatter. LocalDate, LocalTime and LocalDateTime all have a static parse method that takes in a String ...
joecoder's user avatar
  • 325