Groovy类路径问题 [英] Groovy classpath issue

查看:121
本文介绍了Groovy类路径问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Java在本页 RsyntaxTextArea 中运行以下代码,并运行程序完全是在这个网站上提到的方式。而且我得到了预期的输出。但我试图修改这个java代码到Groovy代码,如:

import javax.swing。*
import java.awt。*
swing = new SwingBuilder()
frame = swing.frame(title:test,defaultCloseOperation:JFrame.EXIT_ON_CLOSE,pack: true,show:true,size:[100,100])
{
panel
{
RSyntaxTextArea textArea = new RSyntaxTextArea();
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
}
}

当我尝试运行如下脚本时:

  groovyc -classpath rsyntaxtextarea.jar TextEditorDemo.groovy 

我得到以下错误:

  groovy:9:无法解析class RSyntaxTextArea 
@ line 9,column 19.
RSyntaxTextArea textArea = new RSyntaxTextArea();
$

/home/anto/Groovy/Rsyntax/ST.groovy:9:无法解析class RSyntaxTextArea
@第9行,第30列。
RSyntaxTextArea textArea = new RSyntaxTextArea();
^

/home/anto/Groovy/Rsyntax/ST.groovy:10:无法解析class RSyntaxTextArea
@ line 10,第7列。
textArea。 setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);

我想我在运行程序时犯了错误。我该如何在这种情况下通过定义类路径来运行程序。

解决方案

它看起来不像你导入RSyntaxTextArea的包。您是否尝试将以下导入添加到您的程序中?

  import org.fife.ui.rtextarea。*; 
import org.fife.ui.rsyntaxtextarea。*;


I have run the following code in this page RsyntaxTextArea using Java and i run the program exactly the way that is been mentioned in this site.And i'm getting the output as intended. But i have tried to modify this java code to Groovy code, something like:

import groovy.swing.SwingBuilder
import javax.swing.*
import java.awt.*
swing =  new SwingBuilder()
frame = swing.frame(title : "test", defaultCloseOperation:JFrame.EXIT_ON_CLOSE, pack:true, show : true, size :[100,100])
{
        panel
        {
             RSyntaxTextArea textArea = new RSyntaxTextArea();
             textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
        }
}

And when i try to run this script as follows:

groovyc -classpath rsyntaxtextarea.jar TextEditorDemo.groovy 

I get the errors stating that:

groovy: 9: unable to resolve class RSyntaxTextArea 
 @ line 9, column 19.
        RSyntaxTextArea textArea = new RSyntaxTextArea();
                     ^

/home/anto/Groovy/Rsyntax/ST.groovy: 9: unable to resolve class RSyntaxTextArea 
 @ line 9, column 30.
        RSyntaxTextArea textArea = new RSyntaxTextArea();
                                ^

/home/anto/Groovy/Rsyntax/ST.groovy: 10: unable to resolve class RSyntaxTextArea 
 @ line 10, column 7.
         textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);

I guess i have made wrong in running the program. How i do i run the program in this case by defining the classpath too.

解决方案

It doesn't look like you're importing the package for RSyntaxTextArea. Have you tried adding the following imports to your program?

import org.fife.ui.rtextarea.*;
import org.fife.ui.rsyntaxtextarea.*;

这篇关于Groovy类路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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