Naadiyaar Mansouri

Greenhorn
+ Follow
since Dec 29, 2023
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Naadiyaar Mansouri

Thanks for reply Stephan van Hulst
I was able to run the program using exec-maven-plugin fine but I can't generate a fat jar.
So I updated these attributes of POM:

And tried making jar file by running mvn package however the jar-with-dependencies is not made and I get a normal JAR which returns following error after excuting



Not a “Beginning” topic: moved to our Maven forum.


ok Campbell Ritchie thanks for notifying.
1 month ago
Hi there
I'm trying Jsoup and Maven by following the Jsoup handbook but have issues running the code.
So I created a project using maven and added Jsoup as a dependency, this is the POM:

and this is my only java file:

and tried creating an excutable jar file using both and then running the jar file via but I get this exception:

I would appreciate any help
2 months ago
To compare literals please use equals() method instead of ==. By using == you're actually comparing references rather than contents of variables. So modified version of your code will look like

You can find more information about the difference here:
https://www.javatpoint.com/difference-between-comparing-string-using-equals-equals-and-dot-equals-method-in-java

Edit: Welcome to the Ranch
4 months ago

I have omitted a bit of defensive programming; I challenge you to tell me what it is.



I hope I understood what is in your mind correctly, so in this case since we're accepting any range of int values, getting a negative degree can cause the method to behave unexpectedly and despite its name being cool, it actually warms up the water
Therefor adding another if statement to check int's sign seems like a good idea
6 months ago
I'm reading "Java in a Nutshell" book and in a section about safe java programming it's listing 4 requirements of a safe program which are:

All objects start off in a legal state after creation
Externally accessible methods transition objects between legal states
Externally accessible methods must not return with objects in an inconsistent state
Externally accessible methods must reset objects to a legal state before throwing



the term legal state is repeated a few times here, what is it referring to?
6 months ago
Thanks for your response Campbell Ritchie. I've read the edit 😃
8 months ago
I recently started learning java and now want to know how a concurrent/multithread program is written in Java. I'm aware how these concepts work in Python, but in Java things look different and currently have issues for learning this concepts due to recent changes.
I'd like to follow This guide by Oracle though it's mentioning "Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available."
Considering recent changes like adding Flow APIs in JDK9 or virtual threads in JDK21 I assume best practices are changed also some methods got deprecated since JDK8(?), therefor i have a hard time getting started with concurrency in Java.

I don't have a specific use case right now and just want to start grasping these concepts, though I like to focus on more used methods. So is the oracle tutorial still good enough as a kick-start? Or may I start from newer concepts added? How to determine best practices? Do you suggest any specific book/course/document to follow?
In general any advice would help a lot, thank you.
8 months ago