簡體   English   中英

Javac找不到符號-導入錯誤?

[英]Javac Cannot Find Symbol — Importing errors?

我正在嘗試進行編譯,並且100%肯定我已經正確導入了所有內容。 我的錯誤:

C:\Program Files\Java\jdk1.8.0_111\bin>javac LauncherPanel.java
LauncherPanel.java:8: error: cannot find symbol
import net.minecraft.launcher.Launcher;
                             ^
  symbol:   class Launcher
  location: package net.minecraft.launcher
LauncherPanel.java:9: error: package net.minecraft.launcher.ui.tabs does not exist
import net.minecraft.launcher.ui.tabs.LauncherTabPanel;
                                     ^
LauncherPanel.java:10: error: package net.minecraft.launcher.ui.tabs does not exist
import net.minecraft.launcher.ui.tabs.WebsiteTab;
                                     ^
LauncherPanel.java:19: error: cannot find symbol
  private final LauncherTabPanel tabPanel;
                ^
  symbol:   class LauncherTabPanel
  location: class LauncherPanel
LauncherPanel.java:20: error: cannot find symbol
  private final BottomBarPanel bottomBar;
                ^
  symbol:   class BottomBarPanel
  location: class LauncherPanel
LauncherPanel.java:22: error: cannot find symbol
  private final Launcher launcher;
                ^
  symbol:   class Launcher
  location: class LauncherPanel
LauncherPanel.java:25: error: cannot find symbol
  public LauncherPanel(Launcher launcher)
                       ^
  symbol:   class Launcher
  location: class LauncherPanel
LauncherPanel.java:77: error: cannot find symbol
  public LauncherTabPanel getTabPanel()
         ^
  symbol:   class LauncherTabPanel
  location: class LauncherPanel
LauncherPanel.java:82: error: cannot find symbol
  public BottomBarPanel getBottomBar()
         ^
  symbol:   class BottomBarPanel
  location: class LauncherPanel
LauncherPanel.java:92: error: cannot find symbol
  public Launcher getLauncher()
         ^
  symbol:   class Launcher
  location: class LauncherPanel
LauncherPanel.java:32: error: cannot find symbol
    this.bottomBar = new BottomBarPanel(launcher);
                         ^
  symbol:   class BottomBarPanel
  location: class LauncherPanel
LauncherPanel.java:33: error: cannot find symbol
    this.tabPanel = new LauncherTabPanel(launcher);
                        ^
  symbol:   class LauncherTabPanel
  location: class LauncherPanel
LauncherPanel.java:34: error: cannot find symbol
    this.loginPanel = new TexturedPanel("/cakehoohoohoo.png");
                          ^
  symbol:   class TexturedPanel
  location: class LauncherPanel
LauncherPanel.java:68: error: cannot find symbol
    return new TexturedPanel("/cakehoohoohoo.png");
               ^
  symbol:   class TexturedPanel
  location: class LauncherPanel
14 errors

...這是我的.java文件:

package net.minecraft.launcher.ui;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.GridBagLayout;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import net.minecraft.launcher.Launcher;
import net.minecraft.launcher.ui.tabs.LauncherTabPanel;
import net.minecraft.launcher.ui.tabs.WebsiteTab;
public class LauncherPanel
  extends JPanel
{
  public static final String CARD_DIRT_BACKGROUND = "loading";
  public static final String CARD_LOGIN = "login";
  public static final String CARD_LAUNCHER = "launcher";
  private final CardLayout cardLayout;
  private final LauncherTabPanel tabPanel;
  private final BottomBarPanel bottomBar;
  private final JProgressBar progressBar;
  private final Launcher launcher;
  private final JPanel loginPanel;
  public LauncherPanel(Launcher launcher)
  {
    this.launcher = launcher;
    this.cardLayout = new CardLayout();
    setLayout(this.cardLayout);
    this.progressBar = new JProgressBar();
    this.bottomBar = new BottomBarPanel(launcher);
    this.tabPanel = new LauncherTabPanel(launcher);
    this.loginPanel = new TexturedPanel("/cakehoohoohoo.png");
    createInterface();
  }
  protected void createInterface()
  {
    add(createLauncherInterface(), "launcher");
    add(createDirtInterface(), "loading");
    add(createLoginInterface(), "login");
  }
  protected JPanel createLauncherInterface()
  {
    JPanel result = new JPanel(new BorderLayout());
    this.tabPanel.getBlog().setPage("daxsocial.net16.net");
    JPanel topWrapper = new JPanel();
    topWrapper.setLayout(new BorderLayout());
    topWrapper.add(this.tabPanel, "Center");
    topWrapper.add(this.progressBar, "South");
    this.progressBar.setVisible(false);
    this.progressBar.setMinimum(0);
    this.progressBar.setMaximum(100);
    result.add(topWrapper, "Center");
    result.add(this.bottomBar, "South");
    return result;
  }
  protected JPanel createDirtInterface()
  {
    return new TexturedPanel("/cakehoohoohoo.png");
  }
  protected JPanel createLoginInterface()
  {
    this.loginPanel.setLayout(new GridBagLayout());
    return this.loginPanel;
  }
  public LauncherTabPanel getTabPanel()
  {
    return this.tabPanel;
  }
  public BottomBarPanel getBottomBar()
  {
    return this.bottomBar;
  }
  public JProgressBar getProgressBar()
  {
    return this.progressBar;
  }
  public Launcher getLauncher()
  {
    return this.launcher;
  }
  public void setCard(String card, JPanel additional)
  {
    if (card.equals("login"))
    {
      this.loginPanel.removeAll();
      this.loginPanel.add(additional);
    }
    this.cardLayout.show(this, card);
  }
}

如果有人可以告訴我我在做什么錯,那將非常有幫助! 我用jd-gui.exe反編譯了一個.class文件,然后將代碼復制到一個.txt文檔中,對其進行了編輯,然后另存為一個.java文件。 我現在不能編譯...

該錯誤意味着編譯器找不到類net.minecraft.launcher.Launcher 換句話說,它既不能在源路徑中找到源文件Launcher.java,也不能在類路徑中找到Launcher.class。

假設您尚未創建/更改此類,則可能應將包含Launcher.class的JAR文件添加到類路徑(選項-classpath或環境變量CLASSPATH )中。 否則,您必須調整源路徑(option -sourcepath )-請參閱javac

請注意, import更像是一個快捷方式,因此您可以在代碼中鍵入Launcher而不是net.minecraft.launcher.Launcher

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM