英文:
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
<?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>
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>
或等效路径运行。
另外,值得一提的是,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>
or equivalent.
As a side-note, IntelliJ may be a good alternative to Eclipse, I prefer IntelliJ myself personally.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论