且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Groovy类路径问题

更新时间:2023-12-05 14:17:58

它看起来不像你导入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.*;