在Eclipse IDE环境之外执行Eclipse插件(jdt/ast) [英] Executing Eclipse plugin (jdt/ast) outside eclipse IDE environment

查看:96
本文介绍了在Eclipse IDE环境之外执行Eclipse插件(jdt/ast)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以作为独立过程执行.如您所见,它引用了eclipse/jdt(art)jar文件.我敢肯定,无需下载3.0.2版本,就可以将引用更改为最新版本的jdt/ast.

  • 使用Mac时,我需要用Mac的swt代替PC的swt.我可以在BuildPath/Configure Build path

    1. 首先删除PC swt参考.
    2. 然后添加正确的Mac swt参考.

  • 使用eclipse indigo/在Mac上编译示例

    设置正确后,eclipse开始构建项目.您可以使用项目->构建项目菜单.然后,您可以检查应用程序在eclipse中的运行情况.

    生成可执行jar

    1. 导出到可执行jar文件.
    2. 您会收到一些警告,但是会有一个jar文件.

    执行生成的jar

    在Mac上仅执行 java -jar ast.jar 无效,我从这篇文章中得到了提示.在Mac上正确运行基于SWT的跨平台jar

    简而言之,您需要运行 java -XstartOnFirstThread -jar ast.jar

    Can I execute Eclipse Java development tools as a standalone process? I need to get Java program's AST structure using Eclipse JDT from another program, and to do that, I need to execute eclipse plugin as a stand-alone process behind the scene.

    Is that possible? If so, how one can do that?

    解决方案

    Eclipse/jdt and eclipse/ast is nothing more than a jar file, so one can use them to build standalone java application.

    Example

    I googled to find ASTExplorer as an example to make eclipse/ast plugin as a standalone java project.

    The program was targeted for pretty old eclipse (3.0.2), I downloaded the 3.0.2 for Mac OS X this site - http://archive.eclipse.org/eclipse/downloads/drops/R-3.0.2-200503110845/

    1. You need to setup ECLIPSE_HOME classpath variables in Preference -> Java -> Classpath variables
    2. The .classpath has those classpath variables already, you can refer to this post - .classpath contents update in eclipse. As you can see it refers eclipse/jdt(art) jar files. I'm pretty sure one can change the reference to the newest version of jdt/ast without downloading the 3.0.2 version.
    3. As I use Mac, I need to replace the swt for PC with swt for Mac. I could do that in BuildPath/Configure Build path

      1. First remove the PC swt reference.
      2. Then add the correct Mac swt reference.

    Compile the example with the eclipse indigo/on mac

    When the setup is correct, eclipse starts building the project. You can use Project -> Build Project menu. Then, you can check the application works fine in eclipse.

    Generate the executable jar

    1. Export to executable jar file.
    2. You'll get some warnings, but you'll have a jar file.

    Execute the generated jar

    Just executing java -jar ast.jar doesn't work on Mac, I got a hint from this post. Running SWT based, cross-platform jar properly on a Mac

    In short, you need to run java -XstartOnFirstThread -jar ast.jar

    这篇关于在Eclipse IDE环境之外执行Eclipse插件(jdt/ast)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆