https://software.codidact.com/categories/38/tags/3299.rssNew Posts Tagged 'java' - Software DevelopmentSoftware Development - Codidact2024-03-27T20:49:07Zhttps://software.codidact.com/posts/291167Maven JPA integration: processor not foundtylerbakemanhttps://software.codidact.com/users/804532024-03-26T19:16:20Z2024-03-27T20:49:07Z<p>Personal Project:
I am new to Maven and have spent a few weeks troubleshooting pom errors with chatGPT. Tutorials are hard to come by online, because annotation-processing in Java is more compl...https://software.codidact.com/posts/290964How to log first n lines of a stack trace in Java?propatiencehttps://software.codidact.com/users/690752024-02-28T13:56:51Z2024-02-29T15:04:56Z<p>How to log first n lines of a stack trace in Java?</p>
<!-- g: js, mdit -->https://software.codidact.com/posts/290613How can one import two classes with the same name in Java8?tarhaldahttps://software.codidact.com/users/635912024-01-22T18:45:55Z2024-02-26T05:36:21Z<p>Some development tools provide an error message when a user tries to import two things (classes, packages) with the same name. Some programming languages offer a syntax to import one of those th...https://software.codidact.com/posts/290707MongoDB Java Morphia case insensitive criteria query? propatiencehttps://software.codidact.com/users/690752024-02-06T12:41:00Z2024-02-06T12:42:17Z<p>So I googled some on how to make a case insensitive criteria query but could not find the solution very easily.
So I basically have code that looks like this:</p>
<pre><code>...
query.criteri...https://software.codidact.com/posts/290628What is the purpose of having a wrapper class for JarFile in Spring-boot-loader?Miss Skooterhttps://software.codidact.com/users/655192024-01-24T13:14:47Z2024-02-05T18:23:50Z<p>My question relates to <a href="https://github.com/spring-projects/spring-boot/tree/v2.6.15/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader...https://software.codidact.com/posts/290093Escape both reserved characters and curly braces in a URI in Spring BootFractionalRadixhttps://software.codidact.com/users/530122023-10-24T13:15:29Z2023-10-26T08:44:40Z<p>I need to pass URI's that contain special characters, using Spring Boot.</p>
<p>The characters include spaces, curly braces (<code>{</code> and <code>}</code>), square brackets (<code>[</code> ...https://software.codidact.com/posts/289855How do I properly render a quad in OpenGL using a GL_TRIANGLE_STRIP primitive?cuzzohttps://software.codidact.com/users/538532023-10-01T00:33:41Z2023-10-01T10:11:49Z<p>I am currently working with LWJGL and the obstacle I face right now on my project is rendering textures to a cube, e.x a set of 8 vertices with position, color, and UV information. For now, I am...https://software.codidact.com/posts/288615Clear selectManyMenu component if user unselects item in JSF 2tarhaldahttps://software.codidact.com/users/635912023-06-21T20:03:04Z2023-09-29T11:41:22Z<p>I am working with JSF 2.3 and have a <code>selectManyMenu</code> component that is marked as <code>required</code> but that I want to be cleared if the user unselects all items. Currently, the u...https://software.codidact.com/posts/289778How do I remove an element from a Java array?abhinavxyzhttps://software.codidact.com/users/657132023-09-22T07:24:12Z2023-09-22T12:05:43Z<p>One way to remove element from array is to replace element with zero. Below is a rough snippet I am sharing:</p>
<pre><code class="language-java">int N = sc.nextInt();
int pos = sc.nextInt();
...https://software.codidact.com/posts/289459How to put text next to my ImageIcon on a cell in a JTabledavidalayachewhttps://software.codidact.com/users/649682023-08-20T13:52:48Z2023-08-20T19:27:24Z<p>I have an application that works with a <code>JTable</code>, and in this <code>JTable</code>, I want each cell to have both an <code>ImageIcon</code> and some text.</p>
<p>I see at <a href="htt...https://software.codidact.com/posts/289440How to trigger an error/warning immediately upon compile/run if an item on my class-path is missingdavidalayachewhttps://software.codidact.com/users/649682023-08-18T18:55:23Z2023-08-18T20:02:18Z<p>I have a very simple source file -- <code>HelloWorld.java</code></p>
<pre><code class="language-java">public class HelloWorld
{
public static void main(String[] args)
{
Syst...https://software.codidact.com/posts/289030Log4j2 not looking for log4j.properties even with the system property settarhaldahttps://software.codidact.com/users/635912023-07-20T14:43:57Z2023-07-20T19:50:10Z<p>I am migrating an application from Log4j1 to Log4j2 using the API bridge jar. All references to the log4j1.jar have already been removed.</p>
<p>I set the system property in Websphere as a JVM ...https://software.codidact.com/posts/289017Maven exec:exec fails to see executablesLAFKhttps://software.codidact.com/users/635812023-07-18T19:12:16Z2023-07-18T19:12:16Z<p>I am stumped at Maven exec plugin.</p>
<p>Running <code>mvn exec:exec -Dexec.executable="curl"</code> (or "echo") works. But when running <code>mvn exec:exec</code> or <code>mvn exec:exec@b</co...https://software.codidact.com/posts/288709Running mvn validate does not show rules passed message though it should LAFKhttps://software.codidact.com/users/635812023-06-26T06:39:16Z2023-06-26T06:39:16Z<p>My large, multi-module Maven project validation (Maven Enforcer plug-in) is playing tricks on me.</p>
<p><code>moduleA> mvn validate</code></p>
<ul>
<li>correctly finds all modules</li>
<...https://software.codidact.com/posts/288438DocuSign eSignature API SDK: java.lang.NoClassDefFoundError errors.Vanity Slug ❤️https://software.codidact.com/users/609902023-06-15T13:58:20Z2023-06-17T19:40:05Z<p>I am trying to implement DocuSign's eSignature REST API by using Java SDK. I am following instructions here:</p>
<p><a href="https://developers.docusign.com/docs/esign-rest-api/sdks/java/setup-...https://software.codidact.com/posts/281477Is it worth using the Java Platform Module System in application code?meritonhttps://software.codidact.com/users/532802021-04-22T17:13:32Z2023-06-11T19:34:55Z<p>Is it worth using the Java Platform Module System introduced in Java 9 to structure application code?</p>
<p>Given that the Java Platform Module System introduced in Java 9 doesn't manage depen...https://software.codidact.com/posts/287903How to verify if a year is leap in Java?hkotsubohttps://software.codidact.com/users/530782023-02-16T18:06:39Z2023-02-16T18:24:04Z<p>How to verify if a year is leap?</p>
<p>Given a numeric value (such as <code>2023</code>) or some object that represents a date (such as <a href="https://docs.oracle.com/en/java/javase/15/docs/...https://software.codidact.com/posts/287697Rest service doesn't find @GET Method (Jersey Rest service in Gradle).Gagameliushttps://software.codidact.com/users/586842023-01-11T14:57:50Z2023-01-12T06:14:09Z<p>I have to implement a JSON based REST web service for querying literature. Ordinary users should be able to query data and process it in their clients. The "main user" can adapt database entries...https://software.codidact.com/posts/287551How to proportionally convert a number in the range of -1 and 1 to a number in the range of 0 and 319cuzzohttps://software.codidact.com/users/538532022-12-13T18:44:31Z2022-12-20T22:13:12Z<p>I have float noise values, between -1 and 1, for every x,y coordinate in a 2D area and I am trying to convert that to a whole number between 0 and 319 which represents a vertical z coordinate to...https://software.codidact.com/posts/287498How would I avoid textures being blurred when mapped to a TriangleMesh?cuzzohttps://software.codidact.com/users/538532022-11-29T04:07:28Z2022-11-29T09:11:28Z<p>I am making a game using JavaFX and the Fxyz library. I have chunks which are made of <code>Point3D</code>'s, these points are then passed to a ScatterMesh and that is used to generate a Triangl...https://software.codidact.com/posts/287382Deep linking from another app isn't working for Amazon prime and disney+hotstarbillyhttps://software.codidact.com/users/574282022-11-12T15:14:15Z2022-11-13T06:15:23Z<p>It's not possible to send data to amazon prime and disney+hotstar. I was trying to send user to amazon prime when they click a (video) link (e.g. <a href="https://www.amazon.com/gp/video/detail/...https://software.codidact.com/posts/287362How would I go about chunk loading around player in a 3 dimensional cartesian coordinate spacecuzzohttps://software.codidact.com/users/538532022-11-07T02:53:24Z2022-11-07T17:26:51Z<p>So I am in the process of creating a voxel sandbox survival game (minecraft clone) in javaFX. I am at a point where I need to come up with a way to load the chunks in my surrounding given a rend...https://software.codidact.com/posts/287325Why is IntelliJ not finding these modules?cuzzohttps://software.codidact.com/users/538532022-10-30T17:37:55Z2022-10-31T17:19:37Z<p>So to preface I started a new JavaFX project in IntelliJ and all of this is from what was auto-generated out of the box. The modules I'm having trouble with are</p>
<p><img alt="List of modules...https://software.codidact.com/posts/286151Java cannot find class within same packagecuzzohttps://software.codidact.com/users/538532022-03-24T20:09:10Z2022-10-30T17:46:12Z<p>I've written a class object, <code>QueueObject</code>, but when I try to construct it inside of my main class, it says it cannot find the symbol on compilation. I've read lots of pages saying ho...https://software.codidact.com/posts/286516How to solve missing JAR files error from AntMeganhttps://software.codidact.com/users/566242022-05-27T18:43:32Z2022-06-02T18:01:28Z<p>I keep getting this error:</p>
<pre><code>Cause: the class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec was not found.
This looks like one of Ant's optional components.
Action:...https://software.codidact.com/posts/286480How to open a file and edit its content in groovy scriptMeganhttps://software.codidact.com/users/566242022-05-17T17:37:25Z2022-05-20T14:55:48Z<p>I have a Makefile in my Jenkins job's workspace, that I want to edit out certain parts from and then save it, before running next part of the script that uses this Makefile.</p>
<p>The part tha...https://software.codidact.com/posts/286047How to avoid "exception is never thrown" when commenting out a line while debuggingklutthttps://software.codidact.com/users/81962022-03-02T09:06:46Z2022-03-20T17:07:30Z<p>I have a code block like this:</p>
<pre><code>try {
...
x.foo(); // This is the line that forces us to have the try block
...
} catch (ArrayIndexOutOfBoundsException e) {
l...https://software.codidact.com/posts/286080How can the Caesar cipher be implemented in Java?Holdenhttps://software.codidact.com/users/564272022-03-08T19:29:54Z2022-03-09T12:51:47Z<p>The Caesar cipher is a substitution cipher in which the letters of an ordered alphabet are cyclically shifted by a given number. A detailed description can be found e.g. <a href="https://en.wiki...https://software.codidact.com/posts/286031Mocking methods with argumentsklutthttps://software.codidact.com/users/81962022-02-25T11:35:04Z2022-03-07T12:39:21Z<p>Let's say I have this class I want to mock</p>
<pre><code>class A {
public void add(T arg) {
B b = A.getB();
U val = somefunc(arg);
V ret = b.add(val);
}
}...https://software.codidact.com/posts/286017How to create an object, call one of it's methods and pass it as an argument as a oneliner?klutthttps://software.codidact.com/users/81962022-02-23T12:51:06Z2022-02-24T16:44:16Z<p>Assume I have this class Foo</p>
<pre><code>class Foo {
private int x;
void setX(int x) {
this.x = x;
}
}
</code></pre>
<p>And I have a Junit test like this:</p...https://software.codidact.com/posts/286005How to unittest method that involves contacting remote servers?klutthttps://software.codidact.com/users/81962022-02-22T10:58:30Z2022-02-22T20:59:42Z<p>Let's say I have this class:</p>
<pre><code>class myService {
private boolean foo(T arg) { return arg == 42; }
public Response bar(U arg) {
if(foo(U.field)) {
...https://software.codidact.com/posts/286003How to check if a ldap username is valid without contacting the active directory via ldap?klutthttps://software.codidact.com/users/81962022-02-22T08:38:42Z2022-02-22T19:56:54Z<p>I have some code connecting to an active directory via ldap. Something like this:</p>
<pre><code>public Response add(User user) {
try {
LDAPConnectionPool ldapPool = ldapConnect...https://software.codidact.com/posts/285394How do I properly format a String for parsing with a com.google.gson.JsonParsercuzzohttps://software.codidact.com/users/538532021-12-28T00:54:27Z2022-02-19T17:41:32Z<p>I am trying to check a JSON array for a certain element. However, when I try to instantiate a JsonElement to search the list for:</p>
<pre><code>JsonElement builderElement = JsonParser.parseStr...https://software.codidact.com/posts/285883How to prevent token from being refreshedklutthttps://software.codidact.com/users/81962022-02-09T13:28:08Z2022-02-10T04:11:38Z<p>I have an Angular application. The frontend has a mechanism that periodically fetches some information like this:</p>
<pre><code>ngOnInit(): void {
setInterval( () => {
this.ht...https://software.codidact.com/posts/285784Cannot write multipart message to byte arrayartaxerxehttps://software.codidact.com/users/534832022-02-01T14:06:43Z2022-02-03T16:30:04Z<p>I'm trying to write a MIME message to the console.</p>
<pre><code>ByteArrayOutputStream out = new ByteArrayOutputStream();
MimeMultipart replyMsg = mdnCreator.createMDNData();
replyMsg.writeT...https://software.codidact.com/posts/285493java.lang.UnsupportedClassVersionError: when trying to connect to JDBC with JDK 14 in Eclipsecuzzohttps://software.codidact.com/users/538532022-01-06T19:39:50Z2022-01-07T06:14:11Z<p>I'm trying to connect to a db file in my project but having some troubles. I'm using JDK 14 with ojdbc11 however I am still getting this when trying to connect:</p>
<pre><code>java.lang.Unsuppo...https://software.codidact.com/posts/282832What's the difference between Inheritance and Polymorphism?deleted user#2021-07-25T16:43:53Z2021-10-11T13:49:51Z<h6>I'm using Java code as an example, but this can be answered if you don't know Java.</h6>
<pre><code class="language-java">class Bird{
public void sing(){
System.out.println("...https://software.codidact.com/posts/284357Hash sum mismatch (only for openjdk-11-jdk)Anonymoushttps://software.codidact.com/users/542122021-09-26T10:20:36Z2021-10-05T14:43:12Z<p>I was installing Java yesterday. I had faced lot of problem. I had fixed most of them. But I had changed Hash that's what I think. I don't remember which command I had executed since I had execu...https://software.codidact.com/posts/284414Why I am unable to find a class after implementing library also?Anonymoushttps://software.codidact.com/users/542122021-10-01T03:23:21Z2021-10-01T04:43:19Z<p>I had found a better way to plot in Java.</p>
<pre><code class="language-java"> int n = Integer.parseInt(args[0]);
// the function y = sin(4x) + sin(20x), sampled at n+1 point...https://software.codidact.com/posts/284403Why some items aren't clickable in RecyclerView?Anonymoushttps://software.codidact.com/users/542122021-09-30T07:11:28Z2021-09-30T07:11:28Z<pre><code class="language-java">
if (type=="dialer") {
String timestamp = list.get(position).get(Constants.DATE);
holder.txtTimestamp.setVisibility(View.VISIBLE)...https://software.codidact.com/posts/284343WARNING: environment variable DISPLAY is not set (netbeans)Anonymoushttps://software.codidact.com/users/542122021-09-25T16:32:18Z2021-09-27T15:32:52Z<p>I was trying to install Netbeans in Xubuntu. I had installed Netbeans using Snapd.</p>
<pre><code class="language-bash">sudo snap install netbeans --classic
</code></pre>
<p>I was trying to s...https://software.codidact.com/posts/284311Why is the switch statement not executing the correct case blocks?Anonymoushttps://software.codidact.com/users/542122021-09-23T16:44:22Z2021-09-24T20:37:30Z<p>In the code below, the value of <code>order</code> variable should change according to <code>i</code>'s value:</p>
<pre><code class="language-java">String order;
switch (i){
case 0:
...https://software.codidact.com/posts/284243What are the disadvantages of using static methods in Java?Anonymoushttps://software.codidact.com/users/542122021-09-19T04:53:13Z2021-09-20T16:49:00Z<p>I was using static method few moments ago. But I noticed that I was returning a variable using that static method. According to <a href="https://javabeginnerstutorial.com/core-java-tutorial/publ...https://software.codidact.com/posts/284173What's the minimum API level for activity transition?Anonymoushttps://software.codidact.com/users/542122021-09-13T07:03:34Z2021-09-20T06:13:37Z<p>I was trying to show transition on activity changes. I had followed two method from SO. I lost those link so I can't add them here.</p>
<p>My first method was I had used <code>overridePendingTr...https://software.codidact.com/posts/284246What should I use instead of managedQuery?Anonymoushttps://software.codidact.com/users/542122021-09-19T05:40:46Z2021-09-19T14:24:17Z<p><code>managedQuery</code> is recently deprecated. ManagedQuery was used for using Cursor. What should I use since managedQuery was deprecated? Without it, I can't work with Cursor. So there must...https://software.codidact.com/posts/284248Why ArrayList is always same value in only Adapter?Anonymoushttps://software.codidact.com/users/542122021-09-19T08:09:00Z2021-09-19T09:05:00Z<p>This is the worst bug I have ever seen.. I was fetching CallLogs following way.</p>
<span>
<pre><code class="language-java">ArrayList<HashMap<String, String>> callLog= new ArrayLis...https://software.codidact.com/posts/284236event_start always returning contact number in androidAnonymoushttps://software.codidact.com/users/542122021-09-18T15:36:59Z2021-09-18T15:36:59Z<p>Why <code>ContactsContract.CommonDataKinds.Event.START_DATE</code> always returning contact number. The number is available in Google Contacts.</p>
<p><img alt="img" src="https://imgur.com/BpLR...https://software.codidact.com/posts/284232What's the alternative of "ContactsContract.Contacts.LAST_TIME_CONTACTED"?Anonymoushttps://software.codidact.com/users/542122021-09-18T07:58:53Z2021-09-18T07:59:50Z<p>What should I use instead of <code>ContactsContract.Contacts.LAST_TIME_CONTACTED</code>? According to <a href="https://developer.android.com/reference/android/provider/ContactsContract.ContactOp...https://software.codidact.com/posts/284204Find image for contact list in Android JavaAnonymoushttps://software.codidact.com/users/542122021-09-15T09:25:17Z2021-09-15T10:09:18Z<p>How to get image of contact list? I was using cursor to get contact list. Here how it looks like.</p>
<pre><code class="language-java">ArrayList<HashMap<String, String>> contactList...https://software.codidact.com/posts/279002Proper way of sending large amount of data from View to ViewModelFractionalRadixhttps://software.codidact.com/users/530122020-11-07T07:37:19Z2021-08-24T15:38:03Z<p><strong>The problem</strong></p>
<p>I am working on a simple drawing app for Android. I have a custom view on which the user can draw. This means that a lot of data (a list of points) is genera...