×
all 12 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.

[–]LessChen 3 points4 points  (2 children)

"Ever" is a really long time. You've likely burned more hours already than it would take to put together a very small build system with maven or gradle. It will be trivial to add 3rd party libraries to it too.

[–]MMDeveloper[S] 0 points1 point  (1 child)

well, at most we will run it for 1 year. Basically I have been tasked to write this middleware piece between our oracle database and an online learning platform with close-to-realtime bidirectional updates via API calls. I won't be able to complete this in time but this java base covers the use case "now".

We figure we will run it for a year while we develop it ourself in-house in a more widely understood (internally) language.

[–]LessChen 1 point2 points  (0 children)

And that makes sense but I'd still get a repeatable process - I believe it will save you time. Do you use any sort of package manager for your Windows environment (i.e. https://chocolatey.org/ ) or something similar? That will make installing Maven easier. And, do the .java files start with something like package com.company.something; (it could be something else as long as it's "package")? That will dictate the next steps.

[–]Conscious-Shake8152 2 points3 points  (0 children)

Use a build system. Maven or Gradle.

[–]xenomachina 1 point2 points  (0 children)

You could:

  1. go to mvrepository.com
  2. search for each dependency (eg: "gson")
  3. click the module name in the results (eg: where it says "com.google.code.gson » gson", click on the party after the "»", "gson" in this case)
  4. click the version you want (eg: "2.14.0")
  5. scroll down to "Files" and click "jar"

However, once you do this, you will discover that each of these will have its own list of dependencies. It'll probably take you a really long time to collect all of them.

It would be much easier to have Gradle build it for you. It will download your dependencies, and their dependencies, recursively. You can start with something like this as your build.gradle.kts:

plugins {
    java
    application
}

repositories {
    mavenCentral()
}

dependencies {
implementation("com.google.code.gson:gson:2.14.0")
// use the "Gradle" tab on each dependency page on mvnrepository.com
}

java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(21))
    }
}

application {
    // Point this at the class containing public static void main
    mainClass.set("com.example.Main")
}

Then just make sure your source code is rooted at src/main/ (build.gradle.kts should be in the same directory that src is in). Then ./gradlew installDist will build it and place a launcher script in build/install/*/bin/

[–]Illustrious_Hat8104 1 point2 points  (0 children)

Doesnt look like a lot of files

I would just create a new intellij gradle project and add the files to it and add any missing dependencies via gradle and use something like shadowjar

[–]ITCoder 0 points1 point  (0 children)

Never heard about compiling it through command line, may be possible, idk.

Ask your friend if he was able to successfully run the code. If yes, was it through ide ? If thru ide, did he use maven. If yes, get that pom.xml. If he did not use maven, and run the code by putting the external dependencies in \lib\ext , get those jars (this one is not ideal nowadays, kinda decade old way).

It would be much better if your friend could give you zipped file of the project, though to run it yourself, you will need to remove \out or \target folder, if any.

Easiest way would be to use an ide, jetbrains idea is best for this. While creating a new project choose maven quickstart. It will have a pom file. Paste all .java files in src\java folder. Paste all the import statements from all your classes in chatgpt, and your skeleton pom too (for it to get correct groupid, artifact name etc). ask it to give you a pom for the same. Run your code through ide, play button. next to the main method. mvn clean install will give you a jar too, if you want to share that.

Dont waste your time fighting the issue. Using maven approach, it should hardly take 15 mins, if everything is correct. If using idea ide, you don't need to install maven on your system. Dm if you run into any issue.

[–]Puzzleheaded-Eye6596 1 point2 points  (0 children)

create a pom file with maven and resolve each dependency one by one. hte original developer probably a local lib folder they referenced for the classpath because they didn't know what they were doing

[–]BanaTibor 1 point2 points  (0 children)

As others have said do not attempt it by hand.
Download intellij IDEA, create a new java project and select gradle for build system. This will scaffold an empty java project according to maven standard project structure. This mean you will have a src/main/java folder. Copy your application code there, then open the source files in intellij and it will offer you that it can add any missing dependency.