Questions tagged [java]

622745 questions
1

votes
1

answer
1.2k

Views

Activiti parallel Service Tasks

I am trying to implement two service tasks in activiti which is supposed to run in parallel. The code writen below works fine randomly ( and interestingly ). What I mean by that is that it occasionally prints only 'first' (or 'second') OR it prints two 'first' one 'second' etc. How can i make these...
Le Chat Noir
1

votes
1

answer
710

Views

WebSocket Server (Java) cannot read but send to C# (Unity) Client

For a project in university we should build a multiplayer game. Cause I have quiet a lot experience in Unity I want to use it as Game Engine. We have to use WebSockets for communication and json as protocoll to carry the data. So far so good. C# don´t have a default websocket implementation, so I u...
Snubs
1

votes
1

answer
836

Views

Use Case : Collection.singletonList Vs Collection.unmodifiableList

As I aware that both Collection methods provides read-only access to returned list and throws Exception on modification. I need to understand Use Cases of both so that when to use singletonList and unmodifiableList. This might help me to grow understanding of both based on their usage.
Oomph Fortuity
1

votes
3

answer
47

Views
0

votes
1

answer
66

Views

Why my int[][] is filled with 1 instead of 0?

I'm doing my project with a mouse in the room looking for cheese. In short, I have a board filled with 0 (empty), 1 (random cheese) and 2 (random mouse). First console display is correct, but the second one changes 0 to 1. Any ideas what happened? Random random = new Random(); int cheese = 53 + ran...
Hanna
0

votes
1

answer
45

Views

Random generator creates the same numbers

While looping through a for loop which is randomly 1-10 long. I also go through a while loop. I am trying to find 6 random numbers between 1-42. I then do that again (1-10) times. Currently, these 6 random numbers stay the same. I suspect it has something to do with the seed but I could not solve it...
Davidenko
0

votes
0

answer
42

Views

Override or default value in arguments

I have a method that creates a playlist of the first media file in the list. I need to have ability to do following: add playlist with first media in the list. (Every time it could be different file, which is first in the list.) add playlist with media files that I specify. (Using filenames) How to...
Artur
-3

votes
1

answer
43

Views

Problems with sorting an Array in Java

I´m a bloody beginner trying to write a lil programm to check if 2 words are anagrams. So far all the whitespaces within the words get deleted but apparently there's an error with my Arrays.sort() but I can´t see it. Why and where´s the error in my Arrays.sort() line and how could I solve it? Edi...
grlpwr
-2

votes
0

answer
33

Views

What exactly happening in this program specifically in the return statement?

the actual operation is performed in the line return return (num == 1 ? 1 : num * firstFactorial(num - 1 ) );//how we get //40320 for num 8? public class Factorial { public static int firstFactorial(int num) { return (num == 1 ? 1 : num * firstFactorial(num - 1 ) ); } public static void main(String[...
vijay_ky
-1

votes
2

answer
21

Views

How to fix HashSet that allows duplicates?

I'm using a java.util.Set interface with a java.util.HashSet implementation and storing it in a Map. I add an object to a Set then retrieve the Set object again and am able to add another object that is equal to the first. When adding the seemingly equal objects, Set.add returns true and two equal...
Silo2017
0

votes
1

answer
18

Views

How to get command Line arguments in spring boot?

@SpringBootApplication public class CommandLinetoolApplication { @Value('${person.name}') private String name; public static void main(String... argv) { SpringApplication.run(CommandLinetoolApplication.class, argv); } } I am using eclipse so setting run configuration as -Dspring-boot.run.arguments...
Dhanraj
0

votes
1

answer
22

Views

How to convert a Java Hashmap to a javascript array properly

I want to convert a Java HashMap to a javascript array where the key is inside the javascript object. I have tried to convert the JSON to a javascript object with an array inside. The Java Map looks like this < string: 'sequence', Object: Round> A quick overview of the objects I want to convert fr...
Stefan Gies
1

votes
1

answer
16

Views

Updating objects value when another class updates it

I have 3 classes. Car.java Garage.java Driver.java Race.java So the situation I am in is that I currently have 3 separate classes that are looking and updating each other. The situation is that when Garage updates the Car attributes. Every Car also has assigned Driver. How would I be able to run ack...
AndroidFreak
0

votes
2

answer
21

Views

JPA: How to map only one property from another entity

Let's say I have two entities: @Entity public class Phone { @Id private Long id; private String number; } @Entity public class Person { @Id private Long id; private String name; } The relationship between a person and a phone is one to one. How could I access only the phone's number in the Person en...
Fabian Mendez
3

votes
3

answer
88

Views

What exactly does this log10(int) method in Java?

I'm checking a Java code from an online test and I try to understand what exactly is this log10() method. This is an image with the code from the test: I added the code in my Eclipse and I get some errors: public class Demo { public static String numbers(int from, int to) { int maxDigits = ceil(log...
gaby
0

votes
0

answer
17

Views

How to pass list from jsp to servlet

How to pass list from jsp to servlet? actually, I want to add the dianomic field in my JSP and insert it through a servlet.
Tutan Ghosh
0

votes
1

answer
6

Views

What is best approach in Firebase to save image

I'm new to Firebase services and I saw that offers 3 services to save data: Realtime database, Cloud Firestore and the Storage. I'd like to know what is the best way to approach to Firebase to save image data. The user should upload the image and it need to be saved in a database but which is bette...
Asia Martinis
0

votes
2

answer
50

Views

Can we improve performance on lists other than java 8 parallel streams

I have to dump data from somewhere by calling rest API which returns List. First i have to get some List object from one rest api. Now used parallel stream and gone through each item with forEach. Now on for each element i have to call some other api to get the data which returns again list and save...
Pavan
0

votes
0

answer
3

Views

How to get more metrics(Threads count, Handles Count) other than the compute metrics offered by oracle cloud for an instance?

I launched the windows instance. I found the config.yml file in the oracle cloud agent folder under program files. config.yml file looks like below telemetry: endpoint_format: 'https://telemetry-ingestion.{}.oraclecloud.com' endpoint_path: /20180401/metrics submission_headers: accept: application/js...
karthik_varma_k
3

votes
0

answer
31

Views

When JRE was completely discontinued as separate offering?

Starting from Java 9 the module system was introduced, making provision of JRE separately redundant. Through, it seems that it was still possible to download it. For example, from here now Java 9 archive Also, here it's only stated that : Restructure the JDK and JRE run-time images to draw a clear d...
anasmi
0

votes
4

answer
428

Views

Explain the functionality of JSON

I think it is better to understand why I have so many problems with JSON that I explain you what my goal is: I work with Googles App Engine. There I want to store data. The data looks like user - username question - question date1 - date1 date2 - date2 An Android App have the 'simple' function to: S...
StefMa
-1

votes
1

answer
21

Views

JavaFX update progress bar and wait for threads to complete

I'm trying to update a progress bar in Java FX. My first problem was that the window said 'not responding' instead of actually updating. It just froze and then after the tasks were done, the progress bar became full. So I found out that I had to use multithreading and implemented it like this. overa...
Karan Bijani
0

votes
0

answer
8

Views

Getting “Illegal character(s) in message header field” using google rest client

I am having a issue using Google Client where Java is throwing Exception: 'java.lang.IllegalArgumentException: Illegal character(s) in message header field: :location' I have tried url encoding both the key and value but it produces the same result any help would be great! Code: GenericUrl url = ne...
Jonathan Newton
0

votes
0

answer
4

Views

Scraping web with java and downloading a video

I'm trying to scraping this 9gag link I tried using JSoup to get this HTML tag for taking the source link and download the video directly. I tried with this code public static void main(String[] args) throws IOException { Response response= Jsoup.connect('https://9gag.com/gag/a2ZG6Yd') .ignoreConte...
tassi4224
1

votes
0

answer
6

Views

Different handling of basic authentication in rest client and web app in browser

I have angular frontend and spring backend. I'm using spring security to hande http basic authentication. I noticed strange difference in behaviour using advanced rest client(or any other) and angular web app. For tests I disabled my httpInterceptor so it is not including 'Authorisation: Basic fooba...
skoomi
1

votes
1

answer
3.8k

Views

SSL Handshake exception - RESTEASY004655

I am trying to figure out why am having this type of exception all over the log file!!!! Looking on some internet posts, apparently they talk about network interruption !!! javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request at org.jboss.resteasy.client.jaxrs.engines.ApacheHttp...
Bill
1

votes
1

answer
914

Views

Failed to Insert Image. Permission Denied. Despite providing permission

I'm trying to save Bitmap Image in Gallery of Android Device using MediaStore. Here is my AndroidManifest.xml: As you can see in the manifest file I have provided read and write external storage permission. I have also provided URI permission. I implemented Runtime Permission. Here's my MainActivit...
JaySparkexel
1

votes
2

answer
2.5k

Views

Cassandra CodecNotFoundException: Codec not found for requested operation

I have an enum field that i want to map to a column in cassandra public enum MyEnum { Aa, Bb, Cc, } and here is how i registered it CodecRegistry myCodecRegistry = new CodecRegistry(); myCodecRegistry.register(new EnumOrdinalCodec(MyEnum.class)); cluster = Cluster.builder().addContactPoint(cassandra...
AbtPst
1

votes
1

answer
791

Views

Speech recognition and speech to text on Android without any Google services

I am trying to make an application which uses speech to text for command input. I am making this for Android 6.0.1 and 5.1.1. I started by trying the examples with Google services, but none of them seem to work on my devices. Most of the time there is no clear error or a crash. I have gotten the no...
Timo Loomets
1

votes
2

answer
1.7k

Views

Is there a way in Reactor to ignore error signals?

I have an array of multiple URLs and ports. For each of them, I need to send and receive something back: Flux.fromArray(trackersArray) .flatMap(tracker -> ConnectToTracker.connect(tracker.getTracker(), tracker.getPort())) I communicate with the servers in UDP so I can't tell if a server is alive or...
Stav Alfi
1

votes
2

answer
3.4k

Views

How to resolve java.lang.NoSuchMethodError [duplicate]

This question already has an answer here: How do I fix a NoSuchMethodError? 27 answers I have a project that I can run correctly from within Eclipse, but running the standalone jar gives me the java.lang.NoSuchMethodError for a class at runtime. I unpacked the jar file and can see the class file i...
user2777473
1

votes
1

answer
389

Views

Behaviour of “containsAll” with duplicates

The official documentation (archive) of containsAll only says 'Returns true if this list contains all of the elements of the specified collection.'. However, I just tested this: List list1 = new ArrayList(); list1.add(1); list1.add(2); list1.add(1); List list2 = new ArrayList(); list2.add(2); list2....
Fabian Röling
1

votes
1

answer
550

Views

Right Alignment of numerical value in PDF using Apache PDFBox library

My Spring boot Java application is using apache pdf box library {version 2.0.6} for generating pdf. I want decimal values to be right aligned. It means all decimal dot should align in same vertical line. I also attached screenShot. stream.beginText(); stream.newLineAtOffset(xCordinate, yCordinate);...
1

votes
1

answer
2.6k

Views

Get VMVersionMismatchException when using jmap command

my jdk version is 1.8.0_111 and I'm reading a book on JVM. When I tried the command jmap -F 6469, an exception is thrown as below: Attaching to process ID 6469, please wait... Error attaching to process: sun.jvm.hotspot.runtime.VMVersionMismatchException: Supported versions are 25.111-b14. Target VM...
simon s
1

votes
2

answer
985

Views

Spring Boot app crashes by unknown reasons

I packed my Spring Boot application into jar like others same applications that works correctly. It's almost same apps. But this app failed with errors: 2018-01-28 23:43:57.661 DEBUG 14109 --- [ main] o.s.w.c.s.StandardServletEnvironment : Adding PropertySource 'servletConfigInitParams...
Шах
1

votes
2

answer
2.7k

Views

How to Mock System.getProperty using Mockito

I have added mock-maker-inline text in org.mockito.plugins.MockMaker file and placed it in test/resources/mockito-extensions In my test case I am using: System system = mock(System.class); when(system.getProperty('flag')).thenReturn('true');` But I am getting the following exception: org.mockito.ex...
Raghu
1

votes
2

answer
350

Views

Can using volatile with “AtomicInteger” guarantees thread safety?

Suppose I have private volatile AtomicInteger atomInt = new AtomicInteger(3); and in methods my usage is atomInt.incrementAndGet(). Since I am using AtomicInteger, it will avoid 'thread interference'. And then I am using volatile, so it will guarantee the consistent view of the variable across all...
pjj
1

votes
1

answer
186

Views

TreeMap to Array. Does the array keep the order?

For every time, if I put the same values to the treeMap, the order of data in treeMap will be the same, right? No matter VM etc? I want to find out, if I convert treeMap to array on following way, I get sorted array, for every time in the same order for fixed treeMap. Map treeMap = new TreeMap(); tr...
Hadean
1

votes
1

answer
386

Views

Java JUnit 5 annotations differences

I see there was introduced the new JUnit Jupiter according to JUnit 5 User Guide. JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage I am confused about the same-named annotations I use across the library. Is there any significant difference between these two ones? org.junit.Test org.junit.jup...
Nikolas
1

votes
1

answer
868

Views

Appending to CSV file without headers

I am using opencsv to write a Java bean to a CSV file with headers. The file name contains the current date. If the user runs it for a second time in the same day, it appends to the file but adds another header line. How do I append to the file but without the column headers. public class CSVExport...
Radika Moonesinghe

View additional questions