Basic Java Class Modding (fast and dirty way to class mod)

Lot of tutorials about IL-2 modding: 3D, classes, FM, etc.
Forum rules
Tutorials about IL-2 modding: 3D, classes, FM, etc.
User avatar
FreeIL2Modding
Posts: 1608
Joined: Wed Jun 08, 2016 6:55 pm

Basic Java Class Modding (fast and dirty way to class mod)

Post by FreeIL2Modding » Sat Jun 11, 2016 4:25 pm

Yes, Java Class work (just like any other modding work) will be discussed here. Long the super-secret of certain 'sanctified' individuals that's kept their thumb over this game and the modding thereof, it's time and past time to bring this out into the clean, fresh air.

Now as in most everything else, there are MANY ways to go about class editing. I'm going to show you a fast and sort of 'dirty' way (at least for now) that will have you editing class files and getting those efforts 'in' game quickly. It's not the way I normally mod, but it's effective. I won't be going into GREAT detail. I won't be teaching you Java. I won't be (here anyway) going into the huge amount of changes that can (and cannot) be made, nor the huge problems that can be ran into. But it will work, and if you follow along with me and stick it out, in the end, you'll see the good results.

What you will need:

Java SDK 1.3.1_20 installed upon your computer... this is an old Java SDK, yet it's a complete must.

Get it here: http://java.sun.com/products/archive/j2se/1.3.1_20/
Mediafire download: http://www.mediafire.com/download/yvbm7 ... .1.20.7z#!
Take care to get the SDK -NOT- the JRE! The JRE will NOT work for you. Getting the installation notes and readme may also be helpful.
Basically you can just install it into your computer's C: drive.

Image

You will also need 'these' tools:
NEW LINK MOVED TO BOTTOM OF POST!

They are QTims Modding Tools (the original IL2 hacker) that broke the code.

These Tools contains the following:
A Class Resolver: Decrypts Game's Java classes in order to manipulate them.
Usage:
Java -jar classresolver.jar exampleDir\. (you have to put inside the hashed java class in order to get decrypted, you know the AD3889RS0A1 like files) When its finished you'll see a com folder outside. Inside it you will find the decrypted file)

A Class Hasher: Hashes back (encrypts) Java files in Il2's hashed format.
Usage:
Java -jar classhasher.jar exampleDir\. (you have to put the modified java file INSIDE the com folder. You HAVE TO always work INSIDE the com folder and when its time to hash the file back you should copy the whole com folder containing the file. When its finished you'll see a hashed (or many if you did many files together) files outside.

You use these tools, the Resolver, to open up IL2's java files so you can edit them. You use the Hasher to zip them back into the java format that the game (IL2) can read.

Also included with these tools are the older 'extracted' and 'resolved' files for the game. You can use these, OR you can simply copy the contents of your 4.09M UP2.01 installation's FILES over and use the Resolver on them to get a newer batch of java classes to work with. Note, none of the folders and not all of the java's inside UP's FILES will resolve. But---you'll get the bulk of them, and really that's all you need to start working with java classes.

The next thing you'll need is a Java Editor/compiler/recompiler. NOTE: There are several free and paid for editors that can (more or less) allow you to read and (somewhat) edit java class files. The easiest of these is a payware/shareware proggy called DJ. And you can use 'this' proggy here that's got a fix to it ---if you want to. It's not my proggy and I'm not telling you what to do, use it or not, at your own risk. All I'm saying is that 'here' is a link to it.

NEW LINK MOVED TO BOTTOM OF THIS POST!

If you download and use it that's your business and not mine.

A picture of the DJ type decompiler/recompiler (center open program.)
Image

Now with 'these' files, already you have a way to work with the game's java. There's much more to it, but that's for another post.

QTim's Tools:
http://www.mediafire.com/?a8t5jg1aaxp38v4

DJ Decompiler
http://www.mediafire.com/?vgbvagtbanp9bty
* For any questions, please contact with our admins team by PM, but not with this account
User avatar
FreeIL2Modding
Posts: 1608
Joined: Wed Jun 08, 2016 6:55 pm

Re: Basic Java Class Modding (fast and dirty way to class mo

Post by FreeIL2Modding » Sat Jun 11, 2016 4:26 pm

Setting up your tools to begin Java Class editing:

Ok, there are several ways to do this, here is ONE WAY:

1. Get your Java SDK 1.3.1_20 installed.
2. Install your DJ or other compiler (by the way Jode also works.)
3. Create a Tools folder, you can put it on your desktop (good a place as any and easy to get to.)
4. Inside of your 'Tools' folder create a Javaclasses folder. (Also, you can also place 'other' folders in there * in the Tools folder* for many of your other IL2 'tools' like the Kumpel Matrix tool, Q-Tim's hasher/resolver, etc, etc.
5. But inside your Javaclasses folder, create your 'resolved' java classes. You can have several of these java class folders, for instance one named 'Originals' which are the resolved classes that came with Q-Tim's stuff, and a 'Working' folder with the IL2 classes (the newer ones from UP) that you 'resolved' yourself as stated elsewhere. I personally call my working folder "ModdedClasses" since these are the resolved classes that I took from my UP2.01 FILES folder and many of them have already been 'tinkered' with or modded.
6. Also inside your Javaclasses folder it is helpful to have a folder where you can put things that you are resolving or hashing (with Q-Tim's resolve/hash tools, for instance) and you can call that folder anything you want, I'd call it my 'Beta' folder, for instance. Now it's empty for the time being, and will usually 'stay' empty most of the time, but when you need to resolve or hash something, you can drop it in there and do so without it interfering with 'other' files that are lying around in there, it's a sort of 'working/test' type folder.

Btw, just for your information I also placed the resolver/hasher (Q-Tim's Util tools) programs (not the folder but the actual two tool files) inside my Javaclasses folder, just dropped them in there. It might not matter where they are, but that's just where I put mine.

7. Ok, at this point you're 'just' about ready to start working with java classes. The next thing that throws a 'hell of a lot' of people off, and creates a TON of confusion is the 'SETUP' of your compiler/decompiler! If it's imput and output directions are NOT configured properly it simply won't work, and will not re-compile java class files 'back' into IL2 readable code!

Many a poor guy stumbles here, many a would-be modder quit here because he simple couldn't figure this out by himself or didn't get lucky enough to accidently 'stumble' upon the information he needed to get it to work. And it can be very frustrating, yes, but it is not a problem when you know what to do, and we'll show you what to do. This is 'so' important that we'll start another post on it, so more later.
* For any questions, please contact with our admins team by PM, but not with this account
User avatar
FreeIL2Modding
Posts: 1608
Joined: Wed Jun 08, 2016 6:55 pm

Re: Basic Java Class Modding (fast and dirty way to class mo

Post by FreeIL2Modding » Sat Jun 11, 2016 4:27 pm

As I said in the 'above' post, create that 'Tools' folder on your desktop (does not have to be the desktop but that's how I did it.)

Below are pictures to show you what's inside that 'Tools' folder (again as I mentioned in the post above.)

Image

The below pic is to show you what's inside my 'JavaClasses' folder.

Image

*btw, the 'not' word in the last image should be NOTE...lol, poor spelling/typing, sorry!

:?
* For any questions, please contact with our admins team by PM, but not with this account
User avatar
FreeIL2Modding
Posts: 1608
Joined: Wed Jun 08, 2016 6:55 pm

Re: Basic Java Class Modding (fast and dirty way to class mo

Post by FreeIL2Modding » Sat Jun 11, 2016 4:27 pm

Setting up your compiler properly (and consequently generating your 'first' recompiled java class that will work in game.) So let's do this thing, shall we?

Okay now, if you've installed the compiler correctly and have your TOOLS folder setup right, go into the Tools folder, then into the JavaClasses folder, then into your ModdedClasses folder (or whatever name you're using) and you'll note the layout/structure of it:objec

i.e., com\maddox\il2\objects\air

Yes, you'll see all sorts of other folders and even other java files along the way but leave those for now as we're only concerned with airplanes right now. So navigate until you see the 'air' folder, then go ahead and open that.

if you've installed your compiler properly in windows and have the java SDK installed correctly when you open up the 'air' folder you'll see a LARGE block of aircraft named (and cockpit) java class files. that's it, that's where you want to be.

Image
* For any questions, please contact with our admins team by PM, but not with this account
User avatar
FreeIL2Modding
Posts: 1608
Joined: Wed Jun 08, 2016 6:55 pm

Re: Basic Java Class Modding (fast and dirty way to class mo

Post by FreeIL2Modding » Sat Jun 11, 2016 4:27 pm

Now if your Java SDK and compiler (DJ) are setup in windows properly, the aircraft files inside your 'Air' folder will look like the ones in the above picture, and you 'should' be able to either just click on them (and the compiler will open automatically) or right click and select "open with DJ" and if you do one of those two things the compiler will open that class file.

So let's open one and at the same time we'll go ahead and show you how to get your compiler working the way it's supposed to. Inside your 'Air' folder, scroll down until you see the P_36 class file. That file (as most plane files have) is what's sometimes called a superclass file. Actually it's a mother file, which has the basic coding (like gear, flaps, etc, etc) in it. We do 'not' want to open that file right now, instead look at the P_36A3 file next to it---that is the file we want to use right now.

Highlighting and left clicking (or highlighting and right clicking then choosing 'open with DJ') should immediately open the P_36A3 class file inside the compiler.

Image

Okay, to show you the proper way the compiler should be setup to work, and to get your first workable compiled class file, we're going to make some changes. Really, we're going to make a new P-36 in a new slot.

Go up to the line in DJ that says, "public class P_36A3 extends P_36"

Change the P_36A3 there to P_36X (take care to space it EXACTLY as the old entry was. A space, dash, dot out of place will not let it compile correctly.

Scroll down further until you see the "public P_36A3()" and also change the P-36A3 there to, P_36X.

Scroll on down until you see 'this' entry:

Code: Select all

    static Class _mthclass$(String s)
    {
        Class class1;
        try
        {
            class1 = Class.forName(s);
        }
        catch(ClassNotFoundException classnotfoundexception)
        {
            throw new NoClassDefFoundError(classnotfoundexception.getMessage());
        }
        return class1;
    }

Code: Select all

    static Class _mthclass$(String s)
    {
        try
        {
            return Class.forName(s);
        }
        catch(ClassNotFoundException classnotfoundexception)
        {
            throw new NoClassDefFoundError(classnotfoundexception.getMessage());
    }
Okay, these are 'error' entries that DJ creates in every file that it opens. There's various ways they need to be fixed but the easiest (and quickest) to me is to simple 'backspace' them out one at a time. For now, don't backspace out any of the coding marks...just the WORDS. Do that one entry at a time until you've got that entire thing cleaned up.

It should look like this when you're done:

Image

I highlighted the coding symbols to show that (at this point) I ONLY removed the wording, not the symbols or spaces. They can be removed too and I'll show you that later, but for now I've left them because often the 'noob' guy takes TOO many of them out which can also create an error and this is just a faster way to do it with less errors.

Now scroll down to 'this' line; Class class1 = com.maddox.il2.objects.air.P_36A3.class; and once again change the P_36A3 entry to P_36X ---and that's all of the changes for now.

Now, save the file but do it as a SAVE AS so you can rename the file from P_36A3 to P_36X.
* For any questions, please contact with our admins team by PM, but not with this account
User avatar
FreeIL2Modding
Posts: 1608
Joined: Wed Jun 08, 2016 6:55 pm

Re: Basic Java Class Modding (fast and dirty way to class mo

Post by FreeIL2Modding » Sat Jun 11, 2016 4:29 pm

Now, at the top of DJ, note the place where it says, TOOLS. Clicking there will give you options but he option you want now is COMPILE. Click on Compile and the compile box should automatically open up:

Image

If everything is properly installed and you are in the correct 'air' folder (where you first saw all the aircraft java classes and clicked on the P_36A3 java class) then the compiler screen SHOULD automatically be set up correctly and you're good to go.

To further explain...take a look at all of the PATHS right above the input boxes there in the compiler screen. Take a moment to 'digest' and 'understand' this. Look at every one of them and picture what they're asking for and what's in there.

The top or first path window wants the 'path and file name of the file you're wanting to copy, i.e. the P_36X file you saved.
The second window wants 'destination' directory, i.e. the path and "AIR" directory where you opened up the java aircraft and cockpit files the first time.
The third window wants the path of the java SDK you installed (in C: Drive.)
The fourth window wants the path to the IL2 directory you're working in...i.e. the ModdedClasses folder.
The fifth window is usually the same as the fourth.

It's all pretty self-explaining, but it may seem confusing at first. But once you've seen how it's supposed to look, and understand what is being asked for, it'll make more sense to you. Usually though, if you've followed along with everything so far and are in the correct directory, this will automatically be correct and you won't have to change anything.

If you start working in another IL2 directory though, you may see different things there, which may (or may not work) so you'll just play it by ear if you do that.

Anyway, let's assume everything in the compiler windows are correct and you're about ready to compile.

Okay, before you hit that compile button, look at the middle part of the compiler window. Note the TARGET checkbox. Check it. When you do, the small open window next to it wil become active, scroll down in it until you see 1.3, click on that. At this point your compile window should look like the pic below:

Image

Okay, at this point you should be ready to compile.

Hit the COMPILE button.

If you've installed everything right and followed along CLOSELY to my information above, there should be NO error messages popping up. And the file WILL have compiled. There's no COMPILED message pop up, it'll just be done (so in THIS case not seeing any sort of message is a GOOD THING! lol!)
* For any questions, please contact with our admins team by PM, but not with this account
User avatar
FreeIL2Modding
Posts: 1608
Joined: Wed Jun 08, 2016 6:55 pm

Re: Basic Java Class Modding (fast and dirty way to class mo

Post by FreeIL2Modding » Sat Jun 11, 2016 4:29 pm

To see your newly compiled P_36X class file either close or minimize the DJ proggy and look at the AIR directory (that should be behind it.)

If you give the Air directory a 'new' look, you should quickly spot a NEW folder in there named "com" (without the quotes naturally, lol.)

If you open up that com folder all the way to the end, you'll eventually SEE the newly compiled java class file named, P_36X but don't do anything with it by its self...it MUST stay inside the com folder for now.

Cut the entire new 'com' folder out, navigate BACK to your JavaClasses main folder, find your BETA (or whatever you named it) work folder and PASTE the com folder directly into it.

Now, drop down to your computer's start window...we've got a bit of DOS 'Command Prompt' stuff to do. Don't worry if you've never done this type of stuf before, it is EASY.

Open a Command Promt window.

Image

Okay, so far so good, now you have to 'change directories until you get to the directory where your 'hasher' and resolver' files are located...which if you've followed my tutorial will be located inside your Tools\JavaClasses folder on your desktop.

so, out to the side where your cursor is winking, type:

cd desktop\tools\javaclasses

(the cd means, change Direcotry, the rest is just the path to where your hasher/resolver is located inside your JavaClasses folder. When typing the above entries in, make sure you do it EXACTLY as i've done it with all the spaces and slash marks I have used. If you get a wonky error or can't locate or whatever message, you've probably typed t wrong, keep trying and you'll get it.

When it finds and jumps to the proper directory, you're almost there. Next, type in:

java -jar classhasher.jar beta\.

and then hit the 'enter' key. (Remember to type that command line in EXACTLY as i've shown you in my example!)

If you've done it all correctly, it should not give any sort of error message and should spout some stuff about classhasher v.01 and written by Tim and then jump on down waiting for 'another' command from you. This is all good. It should have 'hashed' that COM file that you placed in the Beta folder a few minutes ago. Close or minimize the Command Prompt window and look at the work space of the JavaClasses folder behind it. You should see this:

Image

That's it! You've just created and hashed your very first IL2 aircraft java class file!
* For any questions, please contact with our admins team by PM, but not with this account
User avatar
FreeIL2Modding
Posts: 1608
Joined: Wed Jun 08, 2016 6:55 pm

Re: Basic Java Class Modding (fast and dirty way to class mo

Post by FreeIL2Modding » Sat Jun 11, 2016 4:30 pm

Ok, to see if it's going to work 'in game,' next we'll make a plane folder for it, put the new class file in there, then add it to the mod's folder STD/air.ini file and give it a test.

Open a NEW window and navigate to your IL2 main directory, find your UP2.01 MODS folder, make a NEW folder in there and call it P_36X. Now, go back to that new 'hashed' java class file you made and cut it out, take it to that NEW P_36X folder and drop it in.

Next, find the STD folder that's also there inside your MODS folder, find the air.ini file, scroll down to the bottom and put this in:

P_36X air.P_36X 1 NOINFO usa01 SUMMER

Save it, then navigate 'back' to your main IL2 directory.

Try to run the game. It 'should' run and load up, and when you go into the Quick Mission Screen you shoud see the P_36X down at the bottom of the plane name window. However, if you look at the 'arming' slot, you'll note it is blank. And if you try to go into the arming screen (where the picture of the plane is) it'll more than likely NOT show it, but rather some other plane instead.

If you try to force it to run in a mission you'll get an error message which says something about the 'default' loadout not being correct!

So, what's wrong is the loadouts inside the class file?

Now I'll show you how to FIX this.
* For any questions, please contact with our admins team by PM, but not with this account
User avatar
FreeIL2Modding
Posts: 1608
Joined: Wed Jun 08, 2016 6:55 pm

Re: Basic Java Class Modding (fast and dirty way to class mo

Post by FreeIL2Modding » Sat Jun 11, 2016 4:30 pm

This is a very common occurance when messing with IL2 modding, especially when dealing with the java class files.

You won't run into it with every plane you mod, but it'll happen enough that you'll soon think it will. lol!

I showed you how to make this new slot on this particular plane and in this particular way because it 'is' such a common occurance that I knew you needed to know how to fix it when it cropped up. I repeat, you will run into 'many' such problems along the modding way to IL2. Every one has a solution, many times more than one solution (as this problem does,) but ALL can be fixed or worked around. Again, there are many ways to fix this (and other) problems you'll be running into, this is the Quick and Dirty way and only 'one' way to do it.

Ok, here's how to fix the problem you've encountered with this plane...remember though, that the 'loadout' section of the java code is VERY finicky and such things will continue to crop up until you've done it so many times you've developed a technique that will stand you in good stead usually.

First off, go BACK to the ModdingClasses folder and it's Air folder and find the P_36X class file you JUST made. You can just click on it to open it in DJ and that's fine only by doing so you 'may' once again have to backspace or delete the "static Class _mthclass$(String s)" errors that i had you delete out a few posts up. Just do it the same way you did before. OR--an easier way (avoiding that error) is to find the P_36X TEXT file that DJ 'also' made when you saved it and highlight it, right click, then select OPEN WITH and then select DJ and that will open it as a java class file. This will open it in DJ but 'without' that error message to mess with!
* For any questions, please contact with our admins team by PM, but not with this account
User avatar
FreeIL2Modding
Posts: 1608
Joined: Wed Jun 08, 2016 6:55 pm

Re: Basic Java Class Modding (fast and dirty way to class mo

Post by FreeIL2Modding » Sat Jun 11, 2016 4:31 pm

Once the new P_36X class is open in DJ, scroll to (near the top) where you'll see 'these' lines:

Code: Select all

package com.maddox.il2.objects.air;

import com.maddox.il2.engine.HierMesh;
import com.maddox.il2.fm.*;
import com.maddox.rts.Property;
Now, below that last entry, add THESE lines:

Code: Select all

import com.maddox.rts.*;
import com.maddox.util.HashMapInt;
import java.util.ArrayList;
So now 'that section' will look like this:

Code: Select all

package com.maddox.il2.objects.air;

import com.maddox.il2.engine.HierMesh;
import com.maddox.il2.fm.*;
import com.maddox.rts.Property;

import com.maddox.rts.*;
import com.maddox.util.HashMapInt;
import java.util.ArrayList;
Okay, so now scroll 'back' down to the start of the loadout section as in the below:

Code: Select all

Aircraft.weaponTriggersRegister(class1, new int[] {
            0, 0, 0, 0, 0, 0
        });
        Aircraft.weaponHooksRegister(class1, new String[] {
            "_MGUN01", "_MGUN02", "_MGUN03", "_MGUN04", "_MGUN05", "_MGUN06"
        });
        Aircraft.weaponsRegister(class1, "default", new String[] {
            "MGunBrowning50si 200", "MGunBrowning50si 200", "MGunBrowning303k 500", "MGunBrowning303k 500", "MGunBrowning303k 500", "MGunBrowning303k 500"
        });
        Aircraft.weaponsRegister(class1, "none", new String[] {
            null, null, null, null, null, null
        });
    }
Go to the EXACT bottom of your DJ file, and highlight everything (all coding--all text and all symbol entries!) Hit the delet key to wipe all of that away, then, copy THIS:

Code: Select all

Aircraft.weaponTriggersRegister(class1, new int[] {
            0, 0, 0, 0, 0, 0
        });
        Aircraft.weaponHooksRegister(class1, new String[] {
            "_MGUN01", "_MGUN02", "_MGUN03", "_MGUN04", "_MGUN05", "_MGUN06"
        });
        try
        {
            ArrayList arraylist = new ArrayList();
            Property.set(class1, "weaponsList", arraylist);
            HashMapInt hashmapint = new HashMapInt();
            Property.set(class1, "weaponsMap", hashmapint);
            byte byte0 = 7;
            String s = "default";
            Aircraft._WeaponSlot a_lweaponslot[] = new Aircraft._WeaponSlot[byte0];
            a_lweaponslot[0] = new Aircraft._WeaponSlot(0, "MGunBrowning50si", 200);
            a_lweaponslot[1] = new Aircraft._WeaponSlot(0, "MGunBrowning50si", 200);
            a_lweaponslot[2] = new Aircraft._WeaponSlot(0, "MGunBrowning303k", 500);
            a_lweaponslot[3] = new Aircraft._WeaponSlot(0, "MGunBrowning303k", 500);
            a_lweaponslot[4] = new Aircraft._WeaponSlot(0, "MGunBrowning303k", 500);
            a_lweaponslot[5] = new Aircraft._WeaponSlot(0, "MGunBrowning303k", 500);    
                 for(int i = 7; i < byte0; i++)
                a_lweaponslot[i] = null;
                
                arraylist.add(s);
            hashmapint.put(Finger.Int(s), a_lweaponslot);
            s = "none";
            a_lweaponslot = new Aircraft._WeaponSlot[byte0];
            for(int j = 0; j < byte0; j++)
                a_lweaponslot[j] = null;

            arraylist.add(s);
            hashmapint.put(Finger.Int(s), a_lweaponslot);
        }
        catch(Exception exception) { }

            }
}
And paste it in its place. Take a good look at it and make sure you copied from the bottom up to the correct line...make sure you don't add or subract any space or anything else. The font and style of your cut and paste may make it look different, but that's okay as far as that goes.

Now, save the file. Now, move over to Tools, and once again COMPILE the class. If everything was done right, again there should be no error messages and when you check your AIR folder it should once again show the Com folder like it did before.

Once again 'cut' out that com folder, move it to the Beta folder (note, there should be an EMPTY com folder inside your beta folder from the first time you did this, simply delete it) in your main JavaClasses folder and paste it there. Once again go to your Command Prompt, and rehash the file JUST LIKE you did the first time.

Again after it hashes there will be a NEW java class file just sitting loose inside your JavaClasses main folder. Once again cut it out, go to your IL2 main directory, find your MODS folder, then your P_36X folder, and repaste it in there. It will as you if you want to overwrite the older file and you simply say, "yes!"

Now, once again start up the game. It should load fine, but THIS time when you look at the plane in Quick Missions you should see the word 'default' in the loadout option window. Also, when you go into the actual loadout section, the plane (merely a copy of the old P-36) should now be visible. If you start a mission using the P_36X, it should load and run fine with NO error messages.

That's it, dude! You've just sucessfully modded IL2!

You've installed all of your needed tools, you've set them all up correctly, you've been into the mysterious java class files, you've learned the basics of DJ, decompiled, edited, saved, and recompiled your first NEW slot plane. You've got it to load in game, you've experienced an error, then learned how to go back and fix that error, and finally and most importantly you're FLYING a modded new plane in the game!

Congradulations and well done!

:D

Image
* For any questions, please contact with our admins team by PM, but not with this account
Post Reply

Return to “Tutorials On IL-2 Modding”

Who is online

Users browsing this forum: No registered users and 1 guest