Solved

How to use the JavaEditorKit under Java 1.4.2_05

Posted on 2004-08-23
24
805 Views
Last Modified: 2007-12-19
Hi,

I am currently running Java 1.4.2_05-b04. I am having trouble running the JavaEditorKit provided by Sun at

http://java.sun.com/products/jfc/tsc/articles/text/editor_kit/

I am getting quite a lot of errors while trying to compile it. Does anyone if there is anything that I can do to get it working?


Thanks!!
0
Comment
Question by:_MW_
  • 10
  • 8
  • 6
24 Comments
 
LVL 92

Expert Comment

by:objects
ID: 11878335
what errors are you getting?
0
 

Author Comment

by:_MW_
ID: 11878337
Um...there is just too many errors....Do you want me to post all the errors?
0
 
LVL 92

Expert Comment

by:objects
ID: 11878343
post the first few and we can start on them :)
0
 

Author Comment

by:_MW_
ID: 11878349
Is it possible for you to try to compile the files provided and have a look at the errors? When you see those errors you would know why I am not posting them here...I think it has something to do with some incompatibility issues as it is an old editor kit. But it seems that these issues may have have been fixed.
0
 

Author Comment

by:_MW_
ID: 11878351
0
 
LVL 92

Expert Comment

by:objects
ID: 11878359
Its already compiled, why do you need to compile it?
0
 

Author Comment

by:_MW_
ID: 11878367
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11878385
place all files in one directory and compile them like this

javac -d . *.java

It solves ur problem
0
 

Author Comment

by:_MW_
ID: 11878405
Hmm...i tried it and it did not work...i get too many compile errors until I ran out of memory..

0
 
LVL 92

Expert Comment

by:objects
ID: 11878413
I don't think sun.tools.java package exists anymore, so you'll probably need to change the code to not use it.
Or use an earlier version of the jdk.
0
 

Author Comment

by:_MW_
ID: 11878432
that's what I thought as well...that's why I was wondering if there was any other way other than using the old jdk versions...This is because the kit provided is ideal for the program I am working on and I would really like to use it and I am hoping that there is a way to use it for the current versions of the jdk...I also found out that one of the classes which is missing is known as Scanner which is available in jdk 1.5...
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11878439
do one thing

import com.sun.java.swing.*;
import com.sun.java.swing.text.*;

replace these two lines

like this
import javax.swing.*;
import javax.swing.text.*;

in all files and javac -d . *.java
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:_MW_
ID: 11878459
I have tried that before....it doesn't work..
0
 
LVL 92

Expert Comment

by:objects
ID: 11878492
> This is because the kit provided is ideal for the program I am working on

What is it you need?

> would really like to use it and I am hoping that there is a way to use it for the current versions of the jdk

No need to either find the required classes, or change the code to not use them.

> I also found out that one of the classes which is missing is known as Scanner which is available in jdk 1.5...

May not actually be the same class
0
 

Author Comment

by:_MW_
ID: 11878514
> This is because the kit provided is ideal for the program I am working on

>What is it you need?

I need a kit that can help me show Java syntax when viewing a source code. So it will be able to do highlighting of Java keywords such as public, int, etc..

> would really like to use it and I am hoping that there is a way to use it for the current versions of the jdk

> No need to either find the required classes, or change the code to not use them.

Don't know where to find the classes =( That's why I am bringing up this problem and hoping that someone had actually been through the same problem as I did and manage to solve it since the JavaEditorKit is a really good plug in provided.

I am not good enough to go in and change the code =(

0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11878537
In Token.java

try to implement the constants like this

public static final int COMMA = 0;
public static final int ASSIGN =1;
public static final int ASGMUL =2;
public static final int ASGDIV =3;
public static final int ASGREM= 4;
public static final int ASGADD=5 ;
public static final int ASGSUB=6;
public static final int ASGLSHIFT=7;

public static final int ASGRSHIFT=8;
public static final int ASGURSHIFT=9;
public static final int ASGBITAND=10;
public static final int ASGBITOR=11;
public static final int ASGBITXOR=12;
public static final int COND=13;
public static final int OR=14;
public static final int AND=15;

and so on

and remove import sun.tools.java.Constants; from that file
0
 
LVL 92

Expert Comment

by:objects
ID: 11878541
try downloading old jdk version and see if it has the required package.
0
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 11878554
Ignore my previous comments about the package not being available in the latest JDK, i missed it when i looked earlier.

you'll find it in <jdk>/lib/tools.jar

just add that to your classpath
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11878572
Just found the API at <JAva>\lib\tool.jar.

You can use that
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11878575
You have already identified that. Didn't refresh
0
 

Author Comment

by:_MW_
ID: 11878612
I added it to the classpath but I am still getting errors such as ..

examples\javakit\GapContent.java:52: package AbstractDocument does not exist
public final class GapContent implements AbstractDocument.Content, Serializable
{
                                                         ^
examples\javakit\GapContent.java:97: cannot resolve symbol
symbol  : class BadLocationException
location: class examples.javakit.GapContent
    public UndoableEdit insertString(int where, String str) throws BadLocationEx
ception {
                                                                   ^
examples\javakit\GapContent.java:115: cannot resolve symbol
symbol  : class BadLocationException
location: class examples.javakit.GapContent
    public UndoableEdit remove(int where, int nitems) throws BadLocationExceptio
n {
                                                             ^
examples\javakit\GapContent.java:133: cannot resolve symbol
symbol  : class BadLocationException
location: class examples.javakit.GapContent
    public String getString(int where, int len) throws BadLocationException {
0
 
LVL 14

Assisted Solution

by:sudhakar_koundinya
sudhakar_koundinya earned 450 total points
ID: 11878622
import javax.swing.text.*;
import javax.swing.*;

as suggested earlier and re compile them again
0
 

Author Comment

by:_MW_
ID: 11878675
It worked!!

Thanks a lot guys for the time and effort spent...
0
 
LVL 92

Expert Comment

by:objects
ID: 11878779
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Starting to learn JAVA, 7 60
Hibernate Not Rolling Back When something fails in a stored procedure 2 52
Java DateChooser? 3 29
servlet doXXX methods 3 39
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now