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

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

Fail to compile due to package not found

问题

  1. <?xml version="1.0"?>
  2. <project default="build" basedir=".">
  3. <property file="build.properties" />
  4. <property name="name" value="Login" />
  5. <property name="src.dir" location="${basedir}/src" />
  6. <property name="build" location="${basedir}/build" />
  7. <property name="build.classes" location="${build}/classes" />
  8. <target name="checkos">
  9. <condition property="bin.dir" value="${basedir}/../../../../bin">
  10. <os family="windows" />
  11. </condition>
  12. <condition property="bin.dir" value="${basedir}/../../../../lib">
  13. <os family="unix" />
  14. </condition>
  15. </target>
  16. <!-- App build -->
  17. <target name="build" depends="checkos" description="Builds the ${name} application">
  18. <mkdir dir="${build.classes}" />
  19. <javac srcdir="${src.dir}"
  20. destdir="${build.classes}"
  21. includeAntRuntime="false"
  22. debug="${build.debug}"
  23. deprecation="true"
  24. verbose="false"
  25. optimize="true"
  26. classpath="${bin.dir}/java/fxcore2.jar">
  27. </javac>
  28. <jar jarfile="${build}/${name}.jar">
  29. <fileset dir="${build.classes}" />
  30. <manifest>
  31. <attribute name="Main-Class" value="login.Main" />
  32. <attribute name="Class-Path" value="fxcore2.jar" />
  33. </manifest>
  34. </jar>
  35. </target>
  36. <target name="rebuild" depends="clean, build" description="Rebuilds project" />
  37. <!-- Clean -->
  38. <target name="clean" description="Removes all temporary files">
  39. <delete dir="${build}" />
  40. </target>
  41. <target name="run" depends="checkos" description="Rebuilds and run ${name}">
  42. <copy file="${bin.dir}/java/fxcore2.jar" tofile="${build}/fxcore2.jar" overwrite="true" />
  43. <java jar="${build}/${name}.jar" fork="true" failonerror='true' dir="${bin.dir}">
  44. <jvmarg value="-Djava.library.path=${java.library.path}${path.separator}${bin.dir}${path.separator}${bin.dir}/java" />
  45. <arg line="--login {LOGIN}" />
  46. <arg line="--password {PASSWORD}" />
  47. <arg line="--url http://www.fxcorporate.com/Hosts.jsp" />
  48. <arg line="--connection Demo" />
  49. <arg line="--sessionid {SESSIONID}" />
  50. <arg line="--pin {PIN}" />
  51. </java>
  52. </target>
  53. </project>

Error output as follows:

  1. Buildfile: C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\build.xml
  2. checkos:
  3. build:
  4. [javac] Compiling 3 source files to C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\build\classes
  5. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:3: error: package fxcm.fxcore2 does not exist
  6. ...
  7. [javac] 18 errors
  8. BUILD FAILED
  9. C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\build.xml:31: Compile failed; see the compiler error output for details.
  10. 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

  1. &lt;?xml version=&quot;1.0&quot;?&gt;
  2. &lt;project default=&quot;build&quot; basedir=&quot;.&quot;&gt;
  3. &lt;property file=&quot;build.properties&quot; /&gt;
  4. &lt;property name=&quot;name&quot; value=&quot;Login&quot; /&gt;
  5. &lt;property name=&quot;src.dir&quot; location=&quot;${basedir}/src&quot; /&gt;
  6. &lt;property name=&quot;build&quot; location=&quot;${basedir}/build&quot; /&gt;
  7. &lt;property name=&quot;build.classes&quot; location=&quot;${build}/classes&quot; /&gt;
  8. &lt;target name=&quot;checkos&quot;&gt;
  9. &lt;condition property=&quot;bin.dir&quot; value=&quot;${basedir}/../../../../bin&quot;&gt;
  10. &lt;os family=&quot;windows&quot; /&gt;
  11. &lt;/condition&gt;
  12. &lt;condition property=&quot;bin.dir&quot; value=&quot;${basedir}/../../../../lib&quot;&gt;
  13. &lt;os family=&quot;unix&quot; /&gt;
  14. &lt;/condition&gt;
  15. &lt;/target&gt;
  16. &lt;!-- App build --&gt;
  17. &lt;target name=&quot;build&quot; depends=&quot;checkos&quot; description=&quot;Builds the ${name} application&quot;&gt;
  18. &lt;!-- Creating directory --&gt;
  19. &lt;mkdir dir=&quot;${build.classes}&quot; /&gt;
  20. &lt;!-- Compiling sources --&gt;
  21. &lt;javac srcdir=&quot;${src.dir}&quot;
  22. destdir=&quot;${build.classes}&quot;
  23. includeAntRuntime=&quot;false&quot;
  24. debug=&quot;${build.debug}&quot;
  25. deprecation=&quot;true&quot;
  26. verbose=&quot;false&quot;
  27. optimize=&quot;true&quot;
  28. classpath=&quot;${bin.dir}/java/fxcore2.jar&quot; &gt;
  29. &lt;/javac&gt;
  30. &lt;!-- Creating JAR-file --&gt;
  31. &lt;jar jarfile=&quot;${build}/${name}.jar&quot;&gt;
  32. &lt;fileset dir=&quot;${build.classes}&quot; /&gt;
  33. &lt;manifest&gt;
  34. &lt;attribute name=&quot;Main-Class&quot; value=&quot;login.Main&quot; /&gt;
  35. &lt;attribute name=&quot;Class-Path&quot; value=&quot;fxcore2.jar&quot; /&gt;
  36. &lt;/manifest&gt;
  37. &lt;/jar&gt;
  38. &lt;/target&gt;
  39. &lt;target name=&quot;rebuild&quot; depends=&quot;clean, build&quot; description=&quot;Rebuilds project&quot; /&gt;
  40. &lt;!-- Clean --&gt;
  41. &lt;target name=&quot;clean&quot; description=&quot;Removes all temporary files&quot;&gt;
  42. &lt;!-- Deleting files --&gt;
  43. &lt;delete dir=&quot;${build}&quot; /&gt;
  44. &lt;/target&gt;
  45. &lt;target name=&quot;run&quot; depends=&quot;checkos&quot; description=&quot;Rebuilds and run ${name}&quot;&gt;
  46. &lt;copy file=&quot;${bin.dir}/java/fxcore2.jar&quot; tofile=&quot;${build}/fxcore2.jar&quot; overwrite=&quot;true&quot; /&gt;
  47. &lt;java jar=&quot;${build}/${name}.jar&quot; fork=&quot;true&quot; failonerror=&#39;true&#39; dir=&quot;${bin.dir}&quot;&gt;
  48. &lt;jvmarg value=&quot;-Djava.library.path=${java.library.path}${path.separator}${bin.dir}${path.separator}${bin.dir}/java&quot; /&gt;
  49. &lt;arg line=&quot;--login {LOGIN}&quot; /&gt;
  50. &lt;arg line=&quot;--password {PASSWORD}&quot; /&gt;
  51. &lt;arg line=&quot;--url http://www.fxcorporate.com/Hosts.jsp&quot; /&gt;
  52. &lt;arg line=&quot;--connection Demo&quot; /&gt;
  53. &lt;arg line=&quot;--sessionid {SESSIONID}&quot; /&gt;
  54. &lt;arg line=&quot;--pin {PIN}&quot; /&gt;
  55. &lt;/java&gt;
  56. &lt;/target&gt;
  57. &lt;/project&gt;

Error output as follow:

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

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

  1. Buildfile: C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\build.xml
  2. checkos:
  3. build:
  4. [javac] Compiling 3 source files to C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\build\classes
  5. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:3: error: package fxcm.fxcore2 does not exist
  6. [javac] import fxcm.fxcore2.*;
  7. [javac] ^
  8. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:45: error: cannot find symbol
  9. [javac] private static void printAccounts(O2GSession session) throws Exception {
  10. [javac] ^
  11. [javac] symbol: class O2GSession
  12. [javac] location: class Main
  13. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:6: error: package com.fxcore2 does not exist
  14. [javac] import com.fxcore2.*;
  15. [javac] ^
  16. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:8: error: cannot find symbol
  17. [javac] public class SessionStatusListener implements IO2GSessionStatus {
  18. [javac] ^
  19. [javac] symbol: class IO2GSessionStatus
  20. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:9: error: cannot find symbol
  21. [javac] private O2GSession mSession;
  22. [javac] ^
  23. [javac] symbol: class O2GSession
  24. [javac] location: class SessionStatusListener
  25. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:18: error: cannot find symbol
  26. [javac] public SessionStatusListener(O2GSession session, String sSessionID, String sPin) {
  27. [javac] ^
  28. [javac] symbol: class O2GSession
  29. [javac] location: class SessionStatusListener
  30. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:48: error: cannot find symbol
  31. [javac] public void onSessionStatusChanged(O2GSessionStatusCode status) {
  32. [javac] ^
  33. [javac] symbol: class O2GSessionStatusCode
  34. [javac] location: class SessionStatusListener
  35. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:9: error: cannot find symbol
  36. [javac] O2GSession session = null;
  37. [javac] ^
  38. [javac] symbol: class O2GSession
  39. [javac] location: class Main
  40. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:22: error: cannot find symbol
  41. [javac] session = O2GTransport.createSession();
  42. [javac] ^
  43. [javac] symbol: variable O2GTransport
  44. [javac] location: class Main
  45. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:46: error: cannot find symbol
  46. [javac] O2GResponseReaderFactory readerFactory = session.getResponseReaderFactory();
  47. [javac] ^
  48. [javac] symbol: class O2GResponseReaderFactory
  49. [javac] location: class Main
  50. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:50: error: cannot find symbol
  51. [javac] O2GLoginRules loginRules = session.getLoginRules();
  52. [javac] ^
  53. [javac] symbol: class O2GLoginRules
  54. [javac] location: class Main
  55. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:51: error: cannot find symbol
  56. [javac] O2GResponse response = loginRules.getTableRefreshResponse(O2GTableType.ACCOUNTS);
  57. [javac] ^
  58. [javac] symbol: class O2GResponse
  59. [javac] location: class Main
  60. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:51: error: cannot find symbol
  61. [javac] O2GResponse response = loginRules.getTableRefreshResponse(O2GTableType.ACCOUNTS);
  62. [javac] ^
  63. [javac] symbol: variable O2GTableType
  64. [javac] location: class Main
  65. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:52: error: cannot find symbol
  66. [javac] O2GAccountsTableResponseReader accountsResponseReader = readerFactory.createAccountsTableReader(response);
  67. [javac] ^
  68. [javac] symbol: class O2GAccountsTableResponseReader
  69. [javac] location: class Main
  70. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\Main.java:54: error: cannot find symbol
  71. [javac] O2GAccountRow accountRow = accountsResponseReader.getRow(i);
  72. [javac] ^
  73. [javac] symbol: class O2GAccountRow
  74. [javac] location: class Main
  75. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:51: error: cannot find symbol
  76. [javac] case TRADING_SESSION_REQUESTED:
  77. [javac] ^
  78. [javac] symbol: variable TRADING_SESSION_REQUESTED
  79. [javac] location: class SessionStatusListener
  80. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:58: error: cannot find symbol
  81. [javac] case CONNECTED:
  82. [javac] ^
  83. [javac] symbol: variable CONNECTED
  84. [javac] location: class SessionStatusListener
  85. [javac] C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\src\SessionStatusListener.java:63: error: cannot find symbol
  86. [javac] case DISCONNECTED:
  87. [javac] ^
  88. [javac] symbol: variable DISCONNECTED
  89. [javac] location: class SessionStatusListener
  90. [javac] 18 errors
  91. BUILD FAILED
  92. C:\Users\clint\Documents\programming\Projects\fxcm\java_sample\NonTableManagerSamples\Login\build.xml:31: Compile failed; see the compiler error output for details.
  93. Total time: 1 second

<!-- end snippet -->

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

答案1

得分: 1

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

  1. ant rebuild
  2. ant run

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

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

英文:

Using the command line, the following commands might work:

  1. ant rebuild
  2. 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:

确定