我是java新手我试图从另一个导入包但另一个不会编译,因为它说它找不到第一个包就是我做的:
首包代码:
package sagar.sql;
import java.sql.Connection;
import java.sql.SQLException;
import oracle.apps.bne.exception.BneException;
import oracle.apps.bne.framework.BneWebAppsContext;
import oracle.apps.bne.utilities.sql.BneBaseSQL;
public class SagarSupplierSiteNameSQL extends BneBaseSQL {
public SagarSupplierSiteNameSQL(BneWebAppsContext paramBneWebAppsContext,
String paramString) throws SQLException,
BneException {
Connection connection = paramBneWebAppsContext.getJDBCConnection();
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("SELECT PARTY_NAME,ACCOUNT_NUMBER,LOCATION WHERE org_id = 281 AND ACCOUNT_NUMBER = :1");
if ((paramString != null) && (!paramString.trim().equals(""))) {
stringBuffer.append("AND " + paramString);
}
//stringBuffer.append(" ORDER BY VENDOR_SITE_CODE, ADDRESS ");
setQuery(connection, stringBuffer.toString());
}
}
第二包代码:
package sagar.validator;
import java.util.Hashtable;
import oracle.apps.bne.exception.BneException;
import oracle.apps.bne.exception.BneFatalException;
import oracle.apps.bne.exception.BneMissingParameterException;
import oracle.apps.bne.framework.BneWebAppsContext;
import oracle.apps.bne.integrator.validators.BneUploadValidator;
import oracle.apps.bne.utilities.sql.BneCompositeSQLCriteria;
import oracle.apps.bne.utilities.sql.BneResultSet;
import oracle.apps.bne.utilities.sql.BneSQLStatement;
import sagar.sql.SagarSupplierSiteNameSQL;
public class SagarSupplierSiteNameValidator extends BneUploadValidator {
public String[] getDomainParameters() {
return new String[] { "P_CUST_NUM" };
}
public BneResultSet getDomainValues(BneWebAppsContext paramBneWebAppsContext,
Hashtable paramHashtable,
BneCompositeSQLCriteria paramBneCompositeSQLCriteria) throws BneException {
SagarSupplierSiteNameSQL sagarSupplierSiteNameSQL = null;
BneResultSet bneResultSet = null;
BneSQLStatement bneSQLStatement1 = new BneSQLStatement();
if (paramBneCompositeSQLCriteria != null) {
bneSQLStatement1 =
paramBneCompositeSQLCriteria.evaluate(bneSQLStatement1);
}
String str1 = (String)paramHashtable.get("P_CUST_NUM");
if (str1 == null) {
throw new BneMissingParameterException("Customer Number Field Error");
}
try {
sagarSupplierSiteNameSQL =
new SagarSupplierSiteNameSQL(paramBneWebAppsContext,
bneSQLStatement1.getStatement());
BneSQLStatement bneSQLStatement2 =
new BneSQLStatement(sagarSupplierSiteNameSQL.getQuery(),
new Object[] { str1 });
bneSQLStatement2.append("", bneSQLStatement1.getBindValues());
bneResultSet =
sagarSupplierSiteNameSQL.getBneResultSet(bneSQLStatement2.getBindValuesAsArray());
} catch (Exception exception) {
throw new BneFatalException(exception.toString());
}
return bneResultSet;
}
}
终端:
-bash-3.00$ javac /apps/DEV/apps/apps_st/comn/java/classes
/SagarSupplierSiteNameSQL.java -d "$JAVA_TOP/sager/sql"
-bash-3.00$
-bash-3.00$
-bash-3.00$
-bash-3.00$
-bash-3.00$ javac /apps/DEV/apps/apps_st/comn/java/classes
/SagarSupplierSiteNameValidator.java -d "$JAVA_TOP/sager/validator"
/apps/DEV/apps/apps_st/comn/java/classes
/SagarSupplierSiteNameValidator.java:15: package sagar.sql does not exist
import sagar.sql.SagarSupplierSiteNameSQL;
^
/apps/DEV/apps/apps_st/comn/java/classes
/SagarSupplierSiteNameValidator.java:27: cannot find symbol
symbol : class SagarSupplierSiteNameSQL
location: class sagar.validator.SagarSupplierSiteNameValidator
SagarSupplierSiteNameSQL sagarSupplierSiteNameSQL = null;
^
/apps/DEV/apps/apps_st/comn/java/classes
/SagarSupplierSiteNameValidator.java:45: cannot find symbol
symbol : class SagarSupplierSiteNameSQL
location: class sagar.validator.SagarSupplierSiteNameValidator
new SagarSupplierSiteNameSQL(paramBneWebAppsContext,
^
`3 errors
如果您需要更多关于我面临的问题的信息,请问我,请帮助我。
答案 0 :(得分:1)
由于您使用的是交叉导入,因此这些文件不会单独编译。您必须立即编译所有文件。
此外,您的类不在java文件顶部的包中。从两个文件中删除package sagar.validator;
和package sagar.sql;
并运行以下命令:
javac /apps/DEV/apps/apps_st/comn/java/*.java
如果您想使用套餐,请移动
文件夹SagarSupplierSiteNameSQL.java
和
/apps/DEV/apps/apps_st/comn/java/sagar/sql
SagarSupplierSiteNameValidator.java
内的 /apps/DEV/apps/apps_st/comn/java/sagar/validator
。
进入/apps/DEV/apps/apps_st/comn/java
,并且以下2个命令中的任何一个都应该有效。
javac **/*.java
或
javac **/**/*.java
答案 1 :(得分:0)
当我使用这两个命令时,它工作得很好:
javac /apps/DEV/apps/apps_st/comn/java/classes/SagarSupplierSiteNameSQL.java -d "$JAVA_TOP"
并且
javac /apps/DEV/apps/apps_st/comn/java/classe/SagarSupplierSiteNameValidator.java -d "$JAVA_TOP"
它自动创建了包的目录,感谢@Pankaj Singhal,因为你的重播引导了我