Stack Overflow » Java
905 FOLLOWERS
Ask all your Java-related questions here and find quality solutions & suggestions. Stack Overflow is the largest, most trusted online community for developers to learn, share their programming knowledge and build their careers.
Stack Overflow » Java
1h ago
My directory structure: java\codes\yash.java
My code is below:
package codes;
public class yash {
public static void main(String[] args) {
System.out.println("Hello world");
}
}
I got error below:
Error: Could not find or load main class yash Caused by: java.lang.NoClassDefFoundError: codes/yash (wrong name: yash)
I tried by keeping yash.java file in java directory instead of code directory where I didn't need to add package in the yash.java file and it worked.
But with the above approach its not working ..read more
Stack Overflow » Java
1h ago
In my application, I need to pick these (sfa, sfb, fbx, obj) specific files which I have saved before, from the file manager in an Android device across different providers
I tried this
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("*/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
//intent.putExtra("CONTENT_TYPE", "*/*");
activityResultLauncher.launch(intent);
but it always opens like this, I don't see any file manager here
If anyone knows how to do this with these file formats (sfa, sfb, fbx, o ..read more
Stack Overflow » Java
1h ago
I have created a cutom tag key and associated value for a particular instance in GCP compute engine. How i can update/delete the tag key by programatically by using google compute engine sdk in java?
Can someone guide me how i can do this? Please provide sample code if possible ..read more
Stack Overflow » Java
1h ago
We want to use @Cacheable in Spring Boot with redis, and we want the redis content to be JSON so it is human readable.
This is done in our CacheConfiguration with
@Autowired
public CacheConfiguration(ObjectMapper objectMapper) {
// we need to modify the default objectMapper for redis so make a copy
this.objectMapper = objectMapper.copy()
.activateDefaultTyping(
objectMapper.getPolymorphicTypeValidator(),
ObjectMapper.DefaultTyping.NON_FINAL,
JsonTypeInfo.As.PROPERTY
);
}
@Bean
public RedisCacheManagerBuilderCustomizer redisCache ..read more
Stack Overflow » Java
1h ago
I have a Spring Boot Java application that exchanges data with an external API using a Feign client. This API only accepts data encoded in Windows-1251 for non-Latin characters. I have configured my Feign client to send the data, and it works fine when it consists of Latin characters only. However, when I need to transfer mixed data, it encodes using Percent Encoding.
Here is an example: The string parameter I need to transfer: Тест The Windows-1251 and then Percent Encoding representation of that string (the desired option): %D2%E5%F1%F2 The Percent Encoding representation of that string only ..read more
Stack Overflow » Java
1h ago
As said in the topic, I wonder if the API of Virtual Threads allow to "jump" straight to another thread we choose. By jumping I mean we at the same time:
park the current thread,
unpark another one (which is currently parked),
ask/suggest the scheduler to start executing the second thread straight away, using the same carrier thread.
The most typical use case for this are generators. We have a producer and consumer without a buffer between them and they don't work concurrently, but we alternate between them. In practice, the consumer "asks" to jump to the producer, and producer asks to jump ..read more
Stack Overflow » Java
1h ago
I have an entity Team with field String name In my service i try to rename the teams, if there is already a team with that name i just throw an exception AlreadyExists. The problem is that when I try to rename team named Clear to CleaR JPA method findByName finds by name 'CleaR' this team 'Clear' (so i can;t rename it) This issue acquires only with letter R, others are ok
I just cant see anything, that leads to such a problem, any ideas ..read more
Stack Overflow » Java
1h ago
So, I'm building an app that only has "Sign In with Google" in order in the name of the authenticated user to upload files to his google drive.
Now my question is, since It's best for my backend to handle the authentication, is it a good approach to set the redirect URI on GCP to be the default URI with the host being the backend? Then after obtaining the access token, saving it to a db, to generate a JWT token for the frontend, in order for the client app to know that the user has been authenticated successfully and send it on each request up until a refresh token is needed, and the backend p ..read more
Stack Overflow » Java
2h ago
After Google Chrome updated to v124 on April 16th, I now cannot run my XML file of 64 tests without freezing and crashing my computer.
I have JDK11 installed. I am using IntelliJ with Maven and selenium-java 4.18.1 The tests would complete fine when I locally ran the XML of 64 tests until Chrome updated.
When I try to run them, half way through I suddenly cannot browse websites and my mouse starts freezing. Then I cannot close any windows or even open Task Manager. I start seeing errors in the IntelliJ console like these:
timeout: Timed out receiving message from renderer and WARNING: Failed t ..read more
Stack Overflow » Java
2h ago
i wrote those codes and when i run them the color not appear in my console and my jdk is 20 and my NetBeans is 21 and i don't know why it isn't working really i need it to work.
package com.mycompany.shaz;
public class Shaz {
final static String red="\u001b[31m";
public static void main(String[] args) {
System.out.println(red+"Hello World!");
String greenBold = "\033[32;1m";
String reset = "\033[0m";
System.out.println("before" + greenBold + " green " + reset + "after");
}
}
i tried to fix it but i didn't find any tutorial to fix it because ..read more