2015-09-04 41 views
-1

我需要生成两个单独的jar文件,它们都相互交互,但做不同的事情。我有两个项目加载到Eclipse中,但都使用了很多相同的导入,因此我将它们放在同一个工作空间下的子文件夹中。Eclipse让我做这个摘要?

其中一人得到"java class xxxx找不到”当我尝试运行它。

当我试图解决这个问题,我是比较两个项目,发现一个文件夹是外部构建路径的一部分但不是非工作的,我把它添加到非工作的工作中,并且打破了工作中的一个

现在工作的那个主类名称有错误我打电话程序ZSTATEngine,等级为

public class ZSTATEngine implements ETOSFilterEngine 

现在这个名字被突出显示,当我将鼠标悬停时,它说:"the type ZSTATEngine必须实现继承的抽象方法ETOSFilterEngine.doFilter(MessageBlock)"

什么可以改变?它之前工作正常,代码本身没有任何改变。我不明白引用的库是如何工作的,但至少在以前的工作项目中,它们的结构没有任何变化。

好了一些进一步的信息:我的确有一个类中的一个部分:

public MessageBlock doFilter(MessageBlock msgBlock) 

所以我采取那个方法......但这种方法现在有它内部的错误,

“在类型FilterFramework的方法addFilteredMessage(MessageBlock)不适用或参数(MessageBlock)...

怎么可能那已经变糟了?它工作也很好。

下面是完整的代码:

package com.ibm.tpf.internal; 

import java.awt.Color; 
/*import java.util.ArrayList;*/ 
/*import java.util.*;*/ 

import com.ibm.tpf.etos.TPFFilter.*; 
//import com.ibm.tpf.etos.TPFFilter.TernarySwitch; 

import com.ibm.tpf.etos.api.*; 
/* 
import com.ibm.tpf.etos.api.Constants; 
import com.ibm.tpf.etos.api.MessageBlock; 
*/ 
import com.ibm.tpf.etos.filter.*; 
/* 
import com.ibm.tpf.etos.filter.ETOSFilterEngine; 
import com.ibm.tpf.etos.filter.FilterConfigurationException; 
import com.ibm.tpf.etos.filter.FilterFramework; 
import com.ibm.tpf.etos.filter.FilterRuntimeException; 
*/ 

public class ZSTATEngine implements ETOSFilterEngine { 
    FilterFramework fw = null; 
    String[] names = null; 

    public ZSTATEngine(FilterFramework filFW, String[] parms) { 
     super(); 
     this.fw = filFW; 
    } 

    /* AAES0009I 13.45.01 FROM TA 05 : AUTC0000I TOSFCOLOR_GREEN TOSBCOLOR_NONE TOSHOLD_0 TOSSAVE_0 TOSALERT_0 AUTC1111I 12.04.41 OK */ 
    public MessageBlock doFilter(MessageBlock msgBlock) throws FilterRuntimeException { 
     if(msgBlock.getMsgID().equals("AAES0009I")) { /* only handle messages that start with AAES0009I */ 
      if(msgBlock.getMsg().indexOf("ZUVRT") != -1) { /* if the message contains "ZUVRT" then let it through. We want to react to the result of it, not the ZUVRT itself. */ 
       return msgBlock; 
      } 
      if(msgBlock.getMsg().indexOf("AUTC0000I") != -1) {  /* search string to see if "AUTC0000I is in it. If it is then do..." */ 
       String myString = msgBlock.getMsg(); 
       Color fColor = Color.WHITE;       /* set default colors */ 
       Color bColor = Color.BLACK; 
       msgBlock.setSuppressed(TernarySwitch.ON);    /* suppress original message to display new one */ 
       String[] myStringParts = myString.split("\\s+",13); /* divide message into 13 parts. The 13th part is everything remaining. */ 
       String finalPart = myStringParts[12].toString();  /* print last part to the screen */ 
       MessageBlock mb = new MessageBlock(finalPart, Constants.ETOS_ONE_MSG); 
       String fColorMsg  = myStringParts[7].toString(); /* Process the foreground color portion */ 
       if (!fColorMsg.contains("NONE")) { 
        fColor = ColorStringInterpreter(fColorMsg); 
        mb.setForeground(fColor); 
       } 
       String bColorMsg  = myStringParts[8].toString(); /* Process the background color portion */ 
       if (!bColorMsg.contains("NONE")) { 
        bColor = ColorStringInterpreter(bColorMsg); 
        mb.setBackground(bColor); 
       } 
       String holdMsg = myStringParts[9].toString();   /* Process the hold message portion */ 
       if (holdMsg.toUpperCase().startsWith("TOS")) {  /* if it starts with TOS, grab only the number at the end */ 
        String[] holdPart = holdMsg.split("_",2); 
        if (holdPart[1].toString().equals("1")) { 
         mb.setHeld(TernarySwitch.ON); 
        } 
       } 
       else { 
        if (holdMsg.equals("1")) {      /* otherwise, just use the number */ 
         mb.setHeld(TernarySwitch.ON); 
        } 
       } 
       String saveMsg = myStringParts[10].toString();  /* Process the save areas. These have two formats currently: TOSSAVE_X_X_X_X and BBBBBBBBB, where X is a digit 1-32, and B is binary. */ 
       if (saveMsg.toUpperCase().startsWith("TOS")) {   
        String[] savePart = saveMsg.split("_");   /* handle the multiple digit save areas, and ignore the first split which is TOSSAVE */ 
        if (!savePart[1].toString().equals("0")) { 
         long areaBits = 0; 
         for (int i=1; i<savePart.length; i++) { 
          areaBits |= 1L << Integer.parseInt(savePart[i]); 
         } 
         mb.setSave(areaBits); 
        } 
       } 
       else {            /* otherwise, just use the binary string directly */ 
        long areaBits = Long.parseLong(myStringParts[10].toString(), 2); 
        mb.setSave(areaBits); 
       } 
       fw.addFilteredMessage(mb);       /* this is the command that pieces the whole message together */ 
      } 
     } 
     int plusLocation = msgBlock.getMsg().lastIndexOf('+'); 
     if (plusLocation > 0) { 
      MessageBlock mb1 = new MessageBlock(msgBlock.getMsg(), msgBlock.getFlag()); 
      fw.addFilteredMessage(mb1); 
      msgBlock.setSuppressed(TernarySwitch.ON); 
      MessageBlock mb2 = new MessageBlock("", Constants.ETOS_ONE_MSG); 
      fw.addFilteredMessage(mb2); 
     } 
     return msgBlock;            /* whatever gets returned is what the system prints */ 
    } 

    private Color ColorStringInterpreter(String colorMsg) throws FilterRuntimeException { 
     if (colorMsg.toUpperCase().startsWith("TOS")) {    /* if it starts with TOS, then we're using color names */ 
      String[] colorParts = colorMsg.split("_",2); 
      String colorTxt  = colorParts[1].toString().trim(); 
      if (colorTxt.toUpperCase() != "NONE") { 
       Color finalColor = Colors.fromString(colorTxt); 
       return finalColor; 
      } 
     } 
     else { 
      String[] colorParts = colorMsg.split("_",3);   /* otherwise we're using RGB values */ 
      String sRed = colorParts[0].toString().trim(); 
      String sGreen = colorParts[1].toString().trim(); 
      String sBlue = colorParts[2].toString().trim(); 
      /*mb = new MessageBlock(sRed, Constants.ETOS_ONE_MSG);*/ 
      int iRed = Integer.parseInt(sRed); 
      int iGreen = Integer.parseInt(sGreen); 
      int iBlue = Integer.parseInt(sBlue); 
      Color finalColor = new Color (iRed, iGreen, iBlue); 
      return finalColor; 
     } 
     return null; 
    } 

    public String getName() { 
     return null; 
    } 

    public void modifyState(Object[] newParams) throws FilterConfigurationException, FilterRuntimeException { 
    } 

    public boolean isActive() { 
     return false; 
    } 

    public void shutdown() { 
    } 
} 
+0

更改原来的问题,以添加更多信息 – TulsaNewbie

+2

您的谩骂正在理解您的问题 – ControlAltDel

+0

也许你有两个版本的ETOSFilterEngine,并且更改后,Eclipse链接到另一个版本。 –

回答

1

正如“Jakub Zaverka”提到的那样,您可能在类路径或构建路径中有两个版本。检查jar命令,是否选择正确的类......即使没有代码发生更改,也会发生。

找到它的一种方法是,只需在ETOSFilterEngine上执行一个F3,然后在包资源管理器中单击“带编辑器的链接”选项即可。它将显示.class文件和它从中拾取的jar。如果它来自错误的jar或旧jar,只需进入Project> Properties> Build Path> Order and Export,然后将正确jar的顺序更改为顶部,通过点击顶部按钮..

+0

做到了!感谢你真正听我说的话,并找出它出了什么问题。我简单地将罐子重新排列到顶部,所有错误都消失了。 – TulsaNewbie

2
public class ZSTATEngine implements ETOSFilterEngine 

根据上面的代码,你的类ZSTATEngine正在实施的接口ETOSFilterEngine,这意味着你的类需要实现ETOSFilterEngine的所有抽象方法。

Java doc

接口形成类和外部世界, 之间的合同,这份合同是由编译器在编译时执行。如果 类宣称实现一个接口,那么在该类将 成功编译之前,该接口定义的所有方法都必须出现在其源代码中。

检查链接:http://www-01.ibm.com/support/knowledgecenter/SSB23S_1.1.0.9/com.ibm.tpfops.doc_1112/aaeo1/fengapi.html?cp=SSB23S_1.1.0.9%2F2-3-10-3

以下是5种方法中存在的ETOSFilterEngine,你需要实现。

public MessageBlock doFilter (MessageBlock) throws 
      FilterRuntimeException; 
    public void modifyState (Object[ ]) throws 
      FilterConfigurationException, 
      FilterRuntimeException; 
    public boolean isActive(); 
    public void shutdown(); 
    public String getName(); 

上面的链接对如何正确地实现这个接口的代码示例。您可以看到示例中的类ZSTATEngine正在实现ETOSFilterEngine提供的所有5种方法。

检查MessageBlock在你的进口类型,它应该是进口 com.ibm.tpf.etos.api.MessageBlock;我可以看到你评论你的导入是错误的。

取消注释该行:import com.ibm.tpf.etos.api.MessageBlock;

+1

这可能是真的,但是......在此之前它运行良好,代码没有改变。 – TulsaNewbie

+0

检查我的编辑特别是最后2行:-) –

+0

取消注释此行:“import com.ibm.tpf.etos.api.MessageBlock;” –

相关问题