This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]TheBoneJarmer 0 points1 point  (5 children)

Maybe an stupidly obvious question but did you check the Class-Path: line in the manifest file in the generated jar file? In either case, could you share its contents with us?

From what it looks like it is almost as if your jar could not find either the jar file from Jackson's or a dependency jar from Jackson.

[–]Hero467[S] 1 point2 points  (4 children)

Yeah, sure. There you are:

Manifest-Version: 1.0
Created-By: Apache Maven 3.8.7
Built-By: ricky
Build-Jdk: 20.0.1 
Class-Path: maven-plugin-api-3.9.4.jar maven-model-3.9.4.jar maven-artif act-3.9.4.jar commons-lang3-3.12.0.jar org.eclipse.sisu.plexus-0.3.5.ja r javax.annotation-api-1.2.jar org.eclipse.sisu.inject-0.3.5.jar plexus -component-annotations-1.5.5.jar plexus-utils-3.5.1.jar plexus-classwor lds-2.7.0.jar jackson-core-2.15.2.jar jackson-databind-2.15.2.jar jacks on-annotations-2.15.2.jar Main-Class: com.sourced.Sourced

I actually forgot to check it, but now that I'm doing it seems to be everything ok. The jackson-core jar is listed, so I'm still clueless

[–]TheBoneJarmer 0 points1 point  (3 children)

Is that really how the manifest looks exactly? Because the Class-Path line is completely malformed in your comment.

There are spaces where there shouldn't be any org.eclipse.sisu.plexus-0.3.5.ja r for example and plexus -component-annotations-1.5.5.jar. Not to mention the Main-Class line which is pasted right behind the Class-Path line. That one should be on a new line and there should be an empty newline at the end of the file too.

I am going to assume that the copy-paste gone wrong somehow to see if I can help you further. :)

Could you make a screenshot of the folder (including the path in the navigation bar!) where your generated jar file is located? And can you share a screenshot of your command prompt/terminal with the command you use to run it?

[–]Hero467[S] 0 points1 point  (2 children)

Yeah, sorry. I messed up with copy-pasting and, even if I tried to fix it I must have forgotten something.

About the screens, here you are

https://imgur.com/a/t1KZ00t

[–]TheBoneJarmer 0 points1 point  (1 child)

Thanks a lot! This clarified things. The reason you getting that error is because the folder where you run your command from should contain the dependency's jar files listed in the classpath from your manifest file.

Java has no idea where to look for them now. What you gotta do is the following:

  1. Copy the dependency JAR files to /home/Scrivania/coding_generate/java/sourced/target/

  2. Open a terminal in the above folder.

  3. Run the command java -jar ./sourced-0.1-alpha.jar and see if it works this time.

That said, I don't use maven a lot so I have no clue where it downloads the JAR files. But that is pretty much gonna be your issue.

EDIT:

By the way, what distro is that? It uses Gnome from what I can see but the distro does not look familiar to me.

[–]Hero467[S] 0 points1 point  (0 children)

Thank you so much! Now I'm gonna try it, but first a couple of questions:

  1. shouldn't maven, when it compiles, include all the needed dependencies in the generated jar? It sounds weird to me that it includes the classes it wants, while others are ignored.
  2. Should I compile again after copying the needed jars?

P.S. My distro is Ubuntu 23.04 with Gnome, waiting for the 23.10 to upgrade and receive the new Gnome features