设置java类路径(对于超级开发模式)

设置java类路径(对于超级开发模式),java,gwt,classpath,gwt-super-dev-mode,Java,Gwt,Classpath,Gwt Super Dev Mode,我试图在OSX.7中使用命令运行一个jar,gwt codeserver.jar java -cp ".:/sdk/gwt-2.5.0.rc1/gwt-dev.jar" -jar /sdk/gwt-2.5.0.rc1/gwt-codeserver.jar com.activegrade.TeacherView 命令失败,原因是: Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gwt/core/ext/

我试图在OSX.7中使用命令运行一个jar,
gwt codeserver.jar

java -cp ".:/sdk/gwt-2.5.0.rc1/gwt-dev.jar" -jar /sdk/gwt-2.5.0.rc1/gwt-codeserver.jar com.activegrade.TeacherView
命令失败,原因是:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gwt/core/ext/TreeLogger
Caused by: java.lang.ClassNotFoundException: com.google.gwt.core.ext.TreeLogger
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    ...
但是gwt-dev.jar包含com.google.gwt.core.ext.TreeLogger的定义,因此我得出结论,我没有在这里正确设置类路径


我是否正确设置了类路径?jar文件绝对是正确的jar,而且它肯定在那个位置。如何进一步诊断此问题?

可能是您问题的根源?“当您使用-jar选项时,jar文件是所有用户类的源,其他用户类路径设置将被忽略。”

您可以像下面那样使用它

java -cp ".:/sdk/gwt-2.5.0.rc1/gwt-dev.jar:/sdk/gwt-2.5.0.rc1/gwt-codeserver.jar" com.activegrade.TeacherView

我已经让CodeServer在Eclipse中作为一个外部工具运行(注意——您仍然需要以某种方式为html文件提供服务器,我还没有这样做,但这似乎确实让CodeServer运行起来)。要在Eclipse中将CodeServer设置为外部工具

0)请记住,您还应该更新module.gwt.xml文件,以允许超级开发模式书本标记,并启用源映射进行调试。将这些喜好添加到module.gwt.xml文件中

<!-- enable the SuperDevMode book marklets  -->
<add-linker name="xsiframe"/>
<set-configuration-property name="devModeRedirectEnabled" value="true"/>

<!--  enable source maps -->
<set-property name="compiler.useSourceMaps" value="true" />
5b)接下来是java.exe应该运行的类的名称。这是CodeServer类

com.google.gwt.dev.codeserver.CodeServer 
5c)接下来是CodeServer的参数。第一个是直接到src的路径。对我来说,这是一个工作空间相对路径

-src "${workspace_loc:\GWTFractionTest\src}" 
5d)最后,这里的模块路径(gwt.xml文件的类路径)是我的

com.conceptua.fractiontest.FractionTest
这是我完整的论点清单

-cp "${eclipse_home}plugins\gwt-2.5.0.rc1\gwt-2.5.0.rc1\gwt-user.jar;${eclipse_home}plugins\gwt-2.5.0.rc1\gwt-2.5.0.rc1\gwt-dev.jar;${workspace_loc:\GWTFractionTest\war\WEB-INF\lib\gwtquery-1.1.0.jar};${eclipse_home}plugins\gwt-2.5.0.rc1\gwt-2.5.0.rc1\gwt-codeserver.jar" com.google.gwt.dev.codeserver.CodeServer -src "${workspace_loc:\GWTFractionTest\src}" com.conceptua.fractiontest.FractionTest
6) 选择“运行”按钮以运行CodeServer。当我在控制台中执行此操作时

workDir: C:\Users\Ezward\AppData\Local\Temp\gwt-codeserver-6942784883227417581.tmp
binding: user.agent=safari
binding: compiler.useSourceMaps=true
binding: locale=en
Compiling module com.conceptua.fractiontest.FractionTest
   Validating units:
      Ignored 72 units with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
   Computing all possible rebind results for 'com.google.gwt.useragent.client.UserAgentAsserter'
      Rebinding com.google.gwt.useragent.client.UserAgentAsserter
         Checking rule <generate-with class='com.google.gwt.editor.rebind.SimpleBeanEditorDriverGenerator'/>
            [WARN] Detected warnings related to 'com.google.gwt.editor.client.SimpleBeanEditorDriver'.   Are validation-api-<version>.jar and validation-api-<version>-sources.jar on the classpath?
            Specify -logLevel DEBUG to see all errors.
            [WARN] Unknown type 'com.google.gwt.editor.client.SimpleBeanEditorDriver' specified in deferred binding rule
   Compiling 1 permutation
      Compiling permutation 0...
      Source Maps Enabled
   Compile of permutations succeeded
Linking into C:\Users\Ezward\AppData\Local\Temp\gwt-codeserver-6942784883227417581.tmp\com.conceptua.fractiontest.FractionTest\compile-1\war\fractiontest; Writing extras to C:\Users\Ezward\AppData\Local\Temp\gwt-codeserver-6942784883227417581.tmp\com.conceptua.fractiontest.FractionTest\compile-1\extras\fractiontest
   Link succeeded
   Compilation succeeded -- 58.257s
Compile completed in 60831 ms
2012-07-01 12:37:03.184::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
2012-07-01 12:37:03.185::INFO:  jetty-6.1.x

The code server is ready.
Next, visit: http://localhxst:9876/
2012-07-01 12:37:03.274::INFO:  Started SelectChannelConnector@127.0.0.1:9876
8) 下一步是访问html文件以运行它。它显然需要由一个单独的Web服务器提供服务。我还在做那部分


Ed

我浪费了很多时间试图让它发挥作用。我试着按照Ezward的指导去做,但我的设置可能有些不同,对我来说不起作用。有许多移动的片段,任何错误都会导致大量空指针、堆栈溢出和无法完成异常


我在(Daniel Kurka博客)上找到的唯一一套对我有用的说明。希望它能帮助像我这样被GWT超级开发模式困住的人。

也有同样的问题。这就是帮助我的原因:

java -cp "./gwt-codeserver.jar:./gwt-dev.jar" com.google.gwt.dev.codeserver.CodeServer
您可以添加--help,如下所示:

java -cp "./gwt-codeserver.jar:./gwt-dev.jar" com.google.gwt.dev.codeserver.CodeServer --help
将输出:

CodeServer [-bindAddress address] [-port port] [-workDir dir] [-src dir] [module]

where 
  -bindAddress  The ip address of the code server. Defaults to 127.0.0.1.
  -port         The port where the code server will run.
  -workDir      The root of the directory tree where the code server willwrite compiler output. If not supplied, a temporary directorywill be used.
  -src          A directory containing GWT source to be prepended to the classpath for compiling.
and 
  module        The GWT modules that the code server should compile. (Example: com.example.MyApp)

然后只需设置您的-src目录和模块的名称

我就可以通过在gwt-dev.jar之外的类路径中添加gwt-user.jar来解决这个问题。GWT超级开发模式表示您可能需要添加GWT-user.jar

java -cp "./gwt-codeserver.jar:./gwt-dev.jar" com.google.gwt.dev.codeserver.CodeServer --help
CodeServer [-bindAddress address] [-port port] [-workDir dir] [-src dir] [module]

where 
  -bindAddress  The ip address of the code server. Defaults to 127.0.0.1.
  -port         The port where the code server will run.
  -workDir      The root of the directory tree where the code server willwrite compiler output. If not supplied, a temporary directorywill be used.
  -src          A directory containing GWT source to be prepended to the classpath for compiling.
and 
  module        The GWT modules that the code server should compile. (Example: com.example.MyApp)