Не удалось скомпилировать из-за того, что пакет не найден - PullRequest
1 голос
/ 30 мая 2020

Проблема : Не удалось выполнить сборку с использованием « Запуск от имени> Сборка Ant » на build.xml

Когда я пытаюсь скомпилировать демо java, он не удалось скомпилировать. Прилагается build.xml и соответствующая настройка затмения. Требуемый пакет установлен, но все еще не удалось скомпилировать.

Вот исходный код демонстрации Вы также можете загрузить этот финансовый инструмент, чтобы повеселиться. Предупреждение: сопряжены с очень высоким риском вложения

<?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">
        <!-- Creating directory -->
        <mkdir dir="${build.classes}" />

        <!-- Compiling sources -->
        <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>

        <!-- Creating JAR-file -->
        <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">
        <!-- Deleting 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>

Вывод ошибки выглядит следующим образом:

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

enter image description here enter image description here

1 Ответ

1 голос
/ 30 мая 2020

Используя командную строку, могут работать следующие команды:

ant rebuild
ant run

из пути C:\Program Files\CandleWorks\ForexConnectAPI\samples\java\NonTableManagerSamples\Login> или эквивалент.

В качестве примечания, IntelliJ может быть хорошей альтернативой вместо Eclipse я лично предпочитаю IntelliJ.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...