-2

I am currently in the process of editing a Minecraft mod slightly to correct an error. I have edited the code successfully, however I have an issue.

In the directory of the JAR file, instead of there being 1 .java file, there's over 90 separate .class files. What makes this even weirder is that when I decompile it using this, all those classes are shown as a .java file.

When I run javac it comes up with an error, I recorded it at https://www.youtube.com/watch?v=KQRreoTSghU

What is going on? How do I split the .java into .class files? Is that the wrong thing to do? And if so, how do I get the code changed?

  • 4
    What's wrong with multiple class files? If the java file has multiple classes declared in it, then multiple class files will be produced. – Sweeper Aug 22 '23 at 05:18
  • @Sweeper I'm new at java, my bad So how do I split the java file into classes? – Heath Pitt Aug 22 '23 at 05:55
  • The source code for java programs is in .java files. Those .java files get compiled into .class files. A .java file can have multiple classes in it, so it will compile to multiple .class files. So you "split the .java file into .class files" by compiling it with javac. – matt Aug 22 '23 at 07:03
  • @matt Ok I did these commands cd C:\Users\[REDACTED]\Downloads javac GiveKillsProcedure.java and it said this: 'GiveKillsProcedure.java:1: error: class, interface, enum, or record expected Decompilers online ^ 1 error' – Heath Pitt Aug 22 '23 at 09:57
  • If you have java code that you're trying to compile. You'll need to post the code and the errors the compiler is giving you. – matt Aug 22 '23 at 10:08
  • @matt Problem is it's INCREDIBLY long it said this when I ran it through the W3Schools Editor/Runner 'Error: class not found: Main.java spoj: The program compiled successfully, but main class was not found. Main class should contain method: public static void main (String[] args).' – Heath Pitt Aug 23 '23 at 04:06
  • 'Too long by 67225 characters' lol – Heath Pitt Aug 23 '23 at 04:07
  • also I'm trying to split the code into multiple class files, idrk if that's compiling or decompiling – Heath Pitt Aug 23 '23 at 04:09
  • "idrk if that's compiling or decompiling" not really either. Compiling is building a program from source code to something that will be interpreted. When you compile a .java program it will produce bytecode that will be interpreted by the jvm. The bytecode will be placed in a .class for each of the classes defined in the java file. – matt Aug 23 '23 at 07:18
  • It helps to have classes in their own .java file. I don't know what this w3schools editor/runner is. I would suggest learning to do it with java/javac You can edit the question to add the complete error message you get when you run javac. I don't know why it says "Decompilers online." javac doesn't say that. – matt Aug 23 '23 at 07:27
  • https://www.youtube.com/watch?v=KQRreoTSghU I recorded the error here if that helps – Heath Pitt Aug 24 '23 at 07:03
  • Honestly I have no clue why it has the error, the code runs fine in Minecraft so I doubt it's a bracket or whatever causes the error usually – Heath Pitt Aug 24 '23 at 07:03
  • "And if so, how do I get the code changed?" If the author of the mod is happy for you to make changes to their code, I'd expect them to provide the original source code, which should make all of this much easier. If their intention is for it to be closed source, I'd personally suggest respecting that decision. – Jon Skeet Aug 24 '23 at 07:13
  • Fair enough, I'll probably leave it be. – Heath Pitt Aug 27 '23 at 10:21

0 Answers0