无法编译,因为找不到包。

huangapple go评论64阅读模式
英文:

Fail to compile due to package not found

问题

<?xml version="1.0"?>
<project default="build" basedir=".">
    <property file="build.properties" />
    <property name="name" value="Login" />
    <property name="src.dir" location="${basedir}/src" />
    <property name="build" location="${basedir}/build" />
    <property name="build.classes" location="${build}/classes" />

    <target name="checkos">
        <condition property="bin.dir" value="${basedir}/../../../../bin">
            <os family="windows" />
        </condition>
        <condition property="bin.dir" value="${basedir}/../../../../lib">
            <os family="unix" />
        </condition>
    </target>

    <!-- App build -->
    <target name="build" depends="checkos" description="Builds the ${name} application">
        <mkdir dir="${build.classes}" />

        <javac srcdir="${src.dir}"
               destdir="${build.classes}"
               includeAntRuntime="false"
               debug="${build.debug}"
               deprecation="true"
               verbose="false"
               optimize="true"
               classpath="${bin.dir}/java/fxcore2.jar">
        </javac>

        <jar jarfile="${build}/${name}.jar">
            <fileset dir="${build.classes}" />
            <manifest>
                <attribute name="Main-Class" value="login.Main" />
                <attribute name="Class-Path" value="fxcore2.jar" />
            </manifest>
        </jar>
    </target>

    <target name="rebuild" depends="clean, build" description="Rebuilds project" />

    <!-- Clean -->
    <target name="clean" description="Removes all temporary files">
        <delete dir="${build}" />
    </target>

    <target name="run" depends="checkos" description="Rebuilds and run ${name}">
        <copy file="${bin.dir}/java/fxcore2.jar" tofile="${build}/fxcore2.jar" overwrite="true" />
        <java jar="${build}/${name}.jar" fork="true" failonerror='true' dir="${bin.dir}">
            <jvmarg value="-Djava.library.path=${java.library.path}${path.separator}${bin.dir}${path.separator}${bin.dir}/java" />
            <arg line="--login {LOGIN}" />
            <arg line="--password {PASSWORD}" />
            <arg line="--url http://www.fxcorporate.com/Hosts.jsp" />
            <arg line="--connection Demo" />
            <arg line="--sessionid {SESSIONID}" />
            <arg line="--pin {PIN}" />
        </java>
    </target>
</project>

Error output as follows:

Buildfile: C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\build.xml
checkos:
build:
    [javac] Compiling 3 source files to C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\build\classes
    [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:3: error: package fxcm.fxcore2 does not exist
    ...
    [javac] 18 errors

BUILD FAILED
C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\build.xml:31: Compile failed; see the compiler error output for details.

Total time: 1 second
英文:

Problem: Failed to build using "Run As > Ant Build" on build.xml

When I try to compile a demo java, it failed to compile. Attached with build.xml and corresponding eclipse setting. Required package in place but still failed to compile.

Here is the demo source code You can download this financial tools to have fun too. Warning: involve very high risk investment

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;project default=&quot;build&quot; basedir=&quot;.&quot;&gt;
&lt;property file=&quot;build.properties&quot; /&gt;
&lt;property name=&quot;name&quot; value=&quot;Login&quot; /&gt;
&lt;property name=&quot;src.dir&quot; location=&quot;${basedir}/src&quot; /&gt;
&lt;property name=&quot;build&quot; location=&quot;${basedir}/build&quot; /&gt;
&lt;property name=&quot;build.classes&quot; location=&quot;${build}/classes&quot; /&gt;
&lt;target name=&quot;checkos&quot;&gt;
&lt;condition property=&quot;bin.dir&quot; value=&quot;${basedir}/../../../../bin&quot;&gt;
&lt;os family=&quot;windows&quot; /&gt;
&lt;/condition&gt;                      
&lt;condition property=&quot;bin.dir&quot; value=&quot;${basedir}/../../../../lib&quot;&gt;
&lt;os family=&quot;unix&quot; /&gt;
&lt;/condition&gt;    
&lt;/target&gt;
&lt;!-- App build --&gt;
&lt;target name=&quot;build&quot; depends=&quot;checkos&quot; description=&quot;Builds the ${name} application&quot;&gt;
&lt;!-- Creating directory --&gt;
&lt;mkdir dir=&quot;${build.classes}&quot; /&gt;
&lt;!-- Compiling sources --&gt;
&lt;javac srcdir=&quot;${src.dir}&quot;
destdir=&quot;${build.classes}&quot;
includeAntRuntime=&quot;false&quot;
debug=&quot;${build.debug}&quot;
deprecation=&quot;true&quot;
verbose=&quot;false&quot;
optimize=&quot;true&quot;
classpath=&quot;${bin.dir}/java/fxcore2.jar&quot; &gt;
&lt;/javac&gt;
&lt;!-- Creating JAR-file --&gt;
&lt;jar jarfile=&quot;${build}/${name}.jar&quot;&gt;
&lt;fileset dir=&quot;${build.classes}&quot; /&gt;
&lt;manifest&gt;
&lt;attribute name=&quot;Main-Class&quot; value=&quot;login.Main&quot; /&gt;
&lt;attribute name=&quot;Class-Path&quot; value=&quot;fxcore2.jar&quot; /&gt;
&lt;/manifest&gt;
&lt;/jar&gt;
&lt;/target&gt;
&lt;target name=&quot;rebuild&quot; depends=&quot;clean, build&quot; description=&quot;Rebuilds project&quot; /&gt;
&lt;!-- Clean --&gt;
&lt;target name=&quot;clean&quot; description=&quot;Removes all temporary files&quot;&gt;
&lt;!-- Deleting files --&gt;
&lt;delete dir=&quot;${build}&quot; /&gt;
&lt;/target&gt;
&lt;target name=&quot;run&quot; depends=&quot;checkos&quot; description=&quot;Rebuilds and run ${name}&quot;&gt;
&lt;copy file=&quot;${bin.dir}/java/fxcore2.jar&quot; tofile=&quot;${build}/fxcore2.jar&quot; overwrite=&quot;true&quot; /&gt;
&lt;java jar=&quot;${build}/${name}.jar&quot; fork=&quot;true&quot; failonerror=&#39;true&#39; dir=&quot;${bin.dir}&quot;&gt;
&lt;jvmarg value=&quot;-Djava.library.path=${java.library.path}${path.separator}${bin.dir}${path.separator}${bin.dir}/java&quot; /&gt;
&lt;arg line=&quot;--login {LOGIN}&quot; /&gt;
&lt;arg line=&quot;--password {PASSWORD}&quot; /&gt;
&lt;arg line=&quot;--url http://www.fxcorporate.com/Hosts.jsp&quot; /&gt;
&lt;arg line=&quot;--connection Demo&quot; /&gt;
&lt;arg line=&quot;--sessionid {SESSIONID}&quot; /&gt;
&lt;arg line=&quot;--pin {PIN}&quot; /&gt;
&lt;/java&gt;
&lt;/target&gt;
&lt;/project&gt;

Error output as follow:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

Buildfile: C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\build.xml
checkos:
build:
[javac] Compiling 3 source files to C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\build\classes
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:3: error: package fxcm.fxcore2 does not exist
[javac] import fxcm.fxcore2.*;
[javac] ^
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:45: error: cannot find symbol
[javac]     private static void printAccounts(O2GSession session) throws Exception {
[javac]                                       ^
[javac]   symbol:   class O2GSession
[javac]   location: class Main
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:6: error: package com.fxcore2 does not exist
[javac] import com.fxcore2.*;
[javac] ^
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:8: error: cannot find symbol
[javac] public class SessionStatusListener implements IO2GSessionStatus {
[javac]                                               ^
[javac]   symbol: class IO2GSessionStatus
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:9: error: cannot find symbol
[javac]     private O2GSession mSession;
[javac]             ^
[javac]   symbol:   class O2GSession
[javac]   location: class SessionStatusListener
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:18: error: cannot find symbol
[javac]     public SessionStatusListener(O2GSession session, String sSessionID, String sPin) {
[javac]                                  ^
[javac]   symbol:   class O2GSession
[javac]   location: class SessionStatusListener
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:48: error: cannot find symbol
[javac]     public void onSessionStatusChanged(O2GSessionStatusCode status) {
[javac]                                        ^
[javac]   symbol:   class O2GSessionStatusCode
[javac]   location: class SessionStatusListener
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:9: error: cannot find symbol
[javac]         O2GSession session = null;
[javac]         ^
[javac]   symbol:   class O2GSession
[javac]   location: class Main
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:22: error: cannot find symbol
[javac]             session = O2GTransport.createSession();
[javac]                       ^
[javac]   symbol:   variable O2GTransport
[javac]   location: class Main
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:46: error: cannot find symbol
[javac]         O2GResponseReaderFactory readerFactory = session.getResponseReaderFactory();
[javac]         ^
[javac]   symbol:   class O2GResponseReaderFactory
[javac]   location: class Main
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:50: error: cannot find symbol
[javac]         O2GLoginRules loginRules = session.getLoginRules();
[javac]         ^
[javac]   symbol:   class O2GLoginRules
[javac]   location: class Main
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:51: error: cannot find symbol
[javac]         O2GResponse response = loginRules.getTableRefreshResponse(O2GTableType.ACCOUNTS);
[javac]         ^
[javac]   symbol:   class O2GResponse
[javac]   location: class Main
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:51: error: cannot find symbol
[javac]         O2GResponse response = loginRules.getTableRefreshResponse(O2GTableType.ACCOUNTS);
[javac]                                                                   ^
[javac]   symbol:   variable O2GTableType
[javac]   location: class Main
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:52: error: cannot find symbol
[javac]         O2GAccountsTableResponseReader accountsResponseReader = readerFactory.createAccountsTableReader(response);
[javac]         ^
[javac]   symbol:   class O2GAccountsTableResponseReader
[javac]   location: class Main
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:54: error: cannot find symbol
[javac]             O2GAccountRow accountRow = accountsResponseReader.getRow(i);
[javac]             ^
[javac]   symbol:   class O2GAccountRow
[javac]   location: class Main
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:51: error: cannot find symbol
[javac]         case TRADING_SESSION_REQUESTED:
[javac]              ^
[javac]   symbol:   variable TRADING_SESSION_REQUESTED
[javac]   location: class SessionStatusListener
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:58: error: cannot find symbol
[javac]         case CONNECTED:
[javac]              ^
[javac]   symbol:   variable CONNECTED
[javac]   location: class SessionStatusListener
[javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:63: error: cannot find symbol
[javac]         case DISCONNECTED:
[javac]              ^
[javac]   symbol:   variable DISCONNECTED
[javac]   location: class SessionStatusListener
[javac] 18 errors
BUILD FAILED
C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\build.xml:31: Compile failed; see the compiler error output for details.
Total time: 1 second

<!-- end snippet -->

无法编译,因为找不到包。
无法编译,因为找不到包。

答案1

得分: 1

使用命令行,以下命令可能有效:

ant rebuild
ant run

从路径 C:\Program Files\CandleWorks\ForexConnectAPI\samples\java\NonTableManagerSamples\Login&gt; 或等效路径运行。

另外,值得一提的是,IntelliJ 可能是 Eclipse 的一个不错替代品,我个人更喜欢 IntelliJ。

英文:

Using the command line, the following commands might work:

ant rebuild
ant run

from the path C:\Program Files\CandleWorks\ForexConnectAPI\samples\java\NonTableManagerSamples\Login&gt; or equivalent.

As a side-note, IntelliJ may be a good alternative to Eclipse, I prefer IntelliJ myself personally.

huangapple
  • 本文由 发表于 2020年5月30日 16:20:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/62099735.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定