Results 1 to 11 of 11
  1. #1
    KamikadZee is offline Member
    Join Date
    Oct 2011
    Posts
    9
    Rep Power
    0

    Default Compile .java to .class, with all errors kept

    So what i need.
    Is to compile .java file (witch ofcourse contains lot of errors but all those errors ar expected and needed, cuz that .java file is from really big package)
    And for example like :
    This imports not exists (in eclipse project or in same folder if i compile with cmd) so I need them kept anyway I don't really care if java compiler sees it as error, and fixes it for me...
    Java Code:
     
    import gnu.trove.TIntIntHashMap;
    import gnu.trove.TIntObjectHashMap;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.math.BigInteger;
    import java.util.Arrays;
    import java.util.List;
    import java.util.Properties;
    import java.util.StringTokenizer;
    import java.util.logging.Logger;
    import javolution.util.FastList;
    import net.sf.l2j.gameserver.util.FloodProtectorConfig;
    import net.sf.l2j.util.StringUtil;
    This was the original import, and while i compile with "Eclipse" using java-builder,

    It gives me sharpen/cut out/fixed/replaced/recreated - f*** code...
    Java Code:
     import FastList;
    import TIntIntHashMap;
    import TIntObjectHashMap;
    import java.io.File;
    import java.util.List;
    import java.util.Properties;
    import java.util.logging.Logger;
    import net.sf.l2j.gameserver.util.FloodProtectorConfig;
    I really wanna use eclipse in future cuz it's like home for me now. But this all compiling situation frustrating me really badly.
    And the worst part, i can't find answer anywhere around the internet,
    And I tried to change preferences In whole eclipse, tried to change preferences in Project menu,
    Well I just didn't find any solution.
    I'm using : jdk1.7.0_01
    Classic Eclipse SDK without any custom plugins,
    So is there anyway configure java compiler to skip errors or it's about eclipse (But i think it javac(compiler))

    I'm sorry for my (hopefully good enough to understand) English.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,958
    Rep Power
    8

    Default Re: Compile .java to .class, with all errors kept

    I'm not sure what you mean. Are you saying that the compiler is removing the unused imports from your .java file? That shouldn't happen, the compiler shouldn't modify the source code at all. What happens when you compile from the command prompt?

    If I understand you correctly, I believe your problem has less to do with the compiler and more to do with an eclipse setting somewhere. I would google something like "eclipse remove unused imports"- if you find out how to turn it on, you should know how to turn it off.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    KamikadZee is offline Member
    Join Date
    Oct 2011
    Posts
    9
    Rep Power
    0

    Default Re: Compile .java to .class, with all errors kept

    Yep i found that. the option in eclipse with unused imports. Eclipse set up fine i'm sure i've been playing around it now for few days with the same problem.

    Compile via cmd gives me this :
    Java Code:
     Config.java:3: error: package gnu.trove does not exist
    import gnu.trove.TIntIntHashMap;
                    ^
    Config.java:4: error: package gnu.trove does not exist
    import gnu.trove.TIntObjectHashMap;
                    ^
    Config.java:16: error: package javolution.util does not exist
    import javolution.util.FastList;
                          ^
    Config.java:17: error: package net.sf.l2j.gameserver.util does not exist
    import net.sf.l2j.gameserver.util.FloodProtectorConfig;
                                     ^
    Config.java:18: error: package net.sf.l2j.util does not exist
    import net.sf.l2j.util.StringUtil;
    and keep going, I know that package doesn't exist, I realize that and I need that.
    Cuz when i get .class file, I'll just put it to .jar file, and everything will work.
    So what i need is to make java compiler skip all errors and just make me .class identical to .java file, with all errors exceptions etc... (even if some not used variables)
    So how to deal with that?

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,958
    Rep Power
    8

    Default Re: Compile .java to .class, with all errors kept

    I'm not sure you can do what you're asking. An import simply tells the compiler which class you mean. For example, if you use a List, the compiler will look to your imports to see whether you mean java.util.List or java.awt.List. If it can't figure out an import, it doesn't know which classes it contains, so it can't go on with its job.

    Why do you think you need to do this?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    KamikadZee is offline Member
    Join Date
    Oct 2011
    Posts
    9
    Rep Power
    0

    Default Re: Compile .java to .class, with all errors kept

    Ok so here full story maybe u will understand me.
    I have .jar files pack(and they connected with each other in .class files) its :
    Java Code:
     
    c3p0-0.9.1.2.jar
    ecj-3.6.2.jar
    java-engine.jar
    javolution.jar
    jython.jar
    jython-engine.jar
    l2jserver.jar
    mmocore.jar
    mysql-connector-java-5.1.14-bin.jar
    trove-2.1.0.jar
    I need to edit only l2jserver.jar
    I decompiled it from .class , to .java with JD-gui, (But ofcorse alone it will have alot of errors, But i really don't care about it cuz i know what i'm editing and doing in that file. Errors will be like : Missing import "import gnu.trove.TIntIntHashMap;" I know that it will work when i put edited class file back to l2jserver.jar)
    so next
    Imported as a project to eclipse, edit it there ant everything looks fine
    I just can't get the source code to .class exactly the same as in .java (Because compiler/builder removes Imports variables which don't exist atm cuz it's taken out of package)
    So what I need, Is to compile .java to .class with exactly the same source skipping error fixes, or any kind of modifications from compiler, i just wanna file same as .java

    I hope this was clear

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,958
    Rep Power
    8

    Default Re: Compile .java to .class, with all errors kept

    Yeah sorry, I don't think there's a good way to do that. Maybe somebody smarter than me can come up with a hack for you, but I'd say your best bet is to just recompile everything you need and make a new Jar.

    Also, why are you decompiling? Don't you have access to the source?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    KamikadZee is offline Member
    Join Date
    Oct 2011
    Posts
    9
    Rep Power
    0

    Default Re: Compile .java to .class, with all errors kept

    I'm completely new to java, (I know just fundamentals of language which allows me to edit game server modifications etc...)
    So decompiling is the easiest way for me for now.

  8. #8
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,958
    Rep Power
    8

    Default Re: Compile .java to .class, with all errors kept

    Quote Originally Posted by KamikadZee View Post
    I'm completely new to java, (I know just fundamentals of language which allows me to edit game server modifications etc...)
    So decompiling is the easiest way for me for now.
    Fair enough. But I think you're hitting one of the many downsides to that approach here. It's going to be a lot easier to work with actual code instead of going back and forth between a .java and .class file.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  9. #9
    KamikadZee is offline Member
    Join Date
    Oct 2011
    Posts
    9
    Rep Power
    0

    Default Re: Compile .java to .class, with all errors kept

    So ok, one more question
    I don't know alot but,
    I can get source code example via SVN client right?
    (Cuz i downloaded entire server files just from simple http, And if do that through SVN, i'll get source code? or I missed something?)

  10. #10
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,958
    Rep Power
    8

    Default Re: Compile .java to .class, with all errors kept

    Quote Originally Posted by KamikadZee View Post
    So ok, one more question
    I don't know alot but,
    I can get source code example via SVN client right?
    (Cuz i downloaded entire server files just from simple http, And if do that through SVN, i'll get source code? or I missed something?)
    It depends on what exactly you're talking about- many open source projects are on SVN, some aren't. But you might want to get a little more acquainted with the basics before you dive into tackling a big project.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  11. #11
    KamikadZee is offline Member
    Join Date
    Oct 2011
    Posts
    9
    Rep Power
    0

    Default Re: Compile .java to .class, with all errors kept

    yeah like i sad i know just fundamentals of object programming so, I'll try to learn java, Just my opinion is solving problems getting big source codes Is the next steps after basics, So you have to think on your self not just listen what others saying, So that's why now i'm trying to edit end setup game server,
    Thank you for your time :) Was nice meeting you. Off for now :)

Similar Threads

  1. help with compile errors
    By bzupnick in forum New To Java
    Replies: 1
    Last Post: 02-15-2011, 08:14 PM
  2. Replies: 4
    Last Post: 01-04-2011, 12:36 AM
  3. compile errors (how do I fix)
    By rhythmiccycle in forum New To Java
    Replies: 4
    Last Post: 01-03-2011, 10:33 PM
  4. Replies: 12
    Last Post: 01-17-2010, 11:05 PM
  5. Help with Compile time errors
    By bri1547 in forum New To Java
    Replies: 2
    Last Post: 08-24-2008, 11:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •