Solved

How to use the JavaEditorKit under Java 1.4.2_05

Posted on 2004-08-23
24
804 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

708 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

13 Experts available now in Live!

Get 1:1 Help Now