-1

I want to change literally one word from a java project on github and compile it to .jar

I cloned the code using github desktop app and open it with visual studio code but there are 259 problems I don't know what.

enter image description here

I forced to compile it anyway, this is the result

enter image description here

Before there was a "JAVA_HOME is not in your enviroment", I googled it and added a new environment with C:\Program Files\Java\jdk1.8.0_221

I have contacted the developer but it seems like they get annoyed I'm asking questions. It is my first time compiling java to jar so please teach me kindly, thank you.

leo
  • 3
  • 2
  • Welcome to Stack Overflow. [Please don't post screenshots of text](https://meta.stackoverflow.com/a/285557/354577). They can't be searched or copied, or even consumed by users of adaptive technologies like screen readers. Instead, paste the code as text directly into your question. If you select it and click the `{}` button or Ctrl+K the code block will be indented by four spaces, which will cause it to be rendered as code. – ChrisGPT was on strike Nov 24 '21 at 23:21

1 Answers1

0

but there are 259 problems I don't know what.

Programs don't live in a vacuum. Specifically, this project uses open source libraries. That's common - just about every modern programming project does. Some ecosystems (such as node.js) elevate it to a competition and even the simplest app include thousands of one-liner open source libraries; java (the ecosystem/community), at least, isn't quite that frivolous with its libraries.

Building a project is, as a consequence, not quite as simple as 'just compile all the java files you can find in the repo'. The source code (the stuff you cloned) contains descriptors of libraries, such as org.apache.commons::commons-lang3::3.12.0 (literally that string or something quite similar to it in a file named pom.xml or build.gradle or build.xml or similar - a file that describes how to build, test, and run the project), and the build tool will then go ahead and download these libraries automatically from open source repositories.

That process gets you the libraries that this project is built on top of, such as org.apache.commons.cli. You didn't run this process, hence why your editor is telling you that it can't find org.apache.commons.cli.

I forced to compile it anyway, this is the result

That obviously doesn't work. An error is an error. Programming is a little harder than just doing your best Harry Potter impression and wishing it away. You'll need to fix this.

Figure out what build tool is used to build it, and use that to build it. Generally the project's readme will explain this. If not, if there is a file named build.gradle, it's gradle, if there's build.xml it is likely ant, and if there is a pom.xml, it's maven. These are all widely used open source tools with hundreds of tutorials on how to use them available. Read up, and get to building!

Only when you successfully build this app in vanilla form (fresh off the clone), should you then start on modifying things.

rzwitserloot
  • 85,357
  • 5
  • 51
  • 72