简体   繁体   中英

Can't make my .java to .class

My errors here
我的错误在这里 I've been searching all over to fix this but I can't make it work and also. I am VERY new to Java.

I extracted a .jar file and then I went to "file.class" because I wanted to change some texts in this "file.class". I made a .java file and now that I try to compile the file.java to file.class it is just not working.

I simply just want to change some text, I am using Eclipse. I've tried to make a new project, and then I built path, added external jars to get the library from my .jar file, then I added "file.jar" with the changes, then I clicked "clean". I get a file.class but with ALOT of errors. I have no clue why and I am sorry if I don't explain this well.

I also tried to do "javac file.java" in CMD but I get errors like "cant find symbol etc etc". What is wrong? What part am I missing? Please explain this well to me, I am very new to java.

package com.eu.habbo.habbohotel.commands;

import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.GameEnvironment;
import com.eu.habbo.habbohotel.catalog.CatalogManager;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.ItemManager;
import com.eu.habbo.habbohotel.rooms.RoomManager;
import com.eu.habbo.habbohotel.users.HabboManager;
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
import gnu.trove.map.TIntObjectMap;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

public class AboutCommand
  extends Command
{
  public AboutCommand()
  {
    super(null, new String[] { "about" });
  }

  public boolean handle(GameClient gameClient, String[] params)
  {
    Emulator.getRuntime().gc();

    int seconds = Emulator.getIntUnixTimestamp() - Emulator.getTimeStarted();
    int day = (int)TimeUnit.SECONDS.toDays(seconds);
    long hours = TimeUnit.SECONDS.toHours(seconds) - day * 24;
    long minute = TimeUnit.SECONDS.toMinutes(seconds) - TimeUnit.SECONDS.toHours(seconds) * 60L;
    long second = TimeUnit.SECONDS.toSeconds(seconds) - TimeUnit.SECONDS.toMinutes(seconds) * 60L;

    gameClient.sendResponse(new GenericAlertComposer("<b>Version: 1.3.0</b>\r\n<b>Hotel Statistik</b>\r- Anvandare: " + 

      Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "\r" + "- Rum: " + 
      Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + "\r" + "- Shop:  " + 
      Emulator.getGameEnvironment().getCatalogManager().catalogPages.size() + " pages and " + CatalogManager.catalogItemAmount + " items. \r" + "- Furni: " + 
      Emulator.getGameEnvironment().getItemManager().getItems().size() + " items." + "\r" + "\n" + "<b>Server Statistik</b>\r" + "- Uptime: " + day + (day > 1 ? " days, " : " day, ") + hours + (hours > 1L ? " hours, " : " hour, ") + minute + (minute > 1L ? " minutes, " : " minute, ") + second + (second > 1L ? " seconds!" : " second!") + "\r" + "- RAM Usage: " + 

      (Emulator.getRuntime().totalMemory() - Emulator.getRuntime().freeMemory()) / 1048576L + "/" + Emulator.getRuntime().freeMemory() / 1048576L + "MB\r" + "- CPU Cores: " + 
      Emulator.getRuntime().availableProcessors() + "\r" + "- Total Memory: " + 
      Emulator.getRuntime().maxMemory() / 1048576L + "MB" + "\r\n" + "<b>Coola Personer:</b> \r" + "- Omega\r" + "- Nille \r" + "- Casanova \r" + "\r" + "<b>Thanks for using Arcturus. Report issues on the forums. http://arcturus.wf \r\r" + "    - The General"));

    return true;
  }
}

The second error in your picture quite clear. It seems like your new project's package name is different with the project in jar file.

Make sure the package name is follow your new project's package name.

This is how you edit a runnable .jar file. First you must download a decompiler. I used this one for my project. http://jd.benow.ca/

Using this program and opening your .jar file will display all source code of the .jar. Now, in order to edit the source code, you must use eclipse. Save it out as a .zip and then open use "Import" with eclipse. The decompiler works well, but it's not 100%, as you may need to clean the source code up a bit in eclipse.

There may be more efficient ways to do this, but this should work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM