0

I need to run this javadoc program for the java file specified below. When i run it i will get the following error message:

Error: unmappable character for encoding UTF8

After several research I found that this error is happening when it finds special characters (the documentation of your java file), and i can get rid of them but that is not an optimal solution.

My question is, is there a way to process the file with any special characters included in your Java file? Have tried to use different econders but cant find the right one.

Special characters being used (" ", -, ©, °, ⌐)

public class JavaDoclet {

/** The current doc, which in this app is a single java file. */
private static RootDoc currentDoc;
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    System.out.println("==========START DOCLET=========");
    String[] cmds = {"-private",
                         "-doclet", JavaDoclet.class.getName(), 
                         "-docletpath", "javadocgrade",
                         "-encoding", "UTF-8",
                         "C:\\Users\\julio\\DispModel.java"};
    int c = com.sun.tools.javadoc.Main.execute(cmds);
    System.out.println("print c -> " + c); //Returns a 1 if it didnt get executed || processed

}

public static boolean start(RootDoc root){

    currentDoc = root;
    ClassDoc[] classes = currentDoc.classes();
   //String tagName = "@param";
    for (int i = 0; i < classes.length; i++){
        System.out.println(classes[i]);

    }
    return true;
}   
  • Are you sure your Java file is *actually* in UTF-8? Do you get the same problem running javadoc from the command line? Can you give us a short example of the source code which is causing the problem? (It should only need to be a few lines long.) – Jon Skeet Jan 30 '14 at 17:09
  • Which source code you want to see? The DispModel.java? I believe im using UTF-8, im using netbeans so im setting the files and the project to encode UTF-8, im not the only one who is having the same issue. – Jcprimo Jan 31 '14 at 17:25
  • The code you're documenting. It doesn't have to be the *actual* code - just a sample which demonstrates the problem. And as I say, could you check whether you get the same problem when you just run javadoc on the command line? – Jon Skeet Jan 31 '14 at 17:27
  • Here it is the DispModel.java //Portion of the code /** * * Copyright © 2004-2006 Board of Regents, New Mexico State University. * * Developed under NMSU Students * * All Rights Reserved * */ package funct.communication.bridge; //End of portion of code OUTPUT: C:\\Users\\julio\\DispModel.java:3: error: unmappable character for encoding UTF8 * Copyright � 2004-2006 Board of Regents, New Mexico State University. And the error its pointing to the Copyright Symbol – Jcprimo Jan 31 '14 at 17:45
  • And (for the third time) do you get an error when running javadoc from the command line? If so, the code you posted in the question is irrelevant. If you could look at the file in a binary file editor and tell us the *bytes* that occur for the copyright symbol, that would be helpful too. – Jon Skeet Jan 31 '14 at 19:29
  • i Keep forgeting to mention, yes i get the same error running it from the command line. Checking the binray file. – Jcprimo Jan 31 '14 at 19:43
  • Right. In that case I suggest you edit the code which is actually causing the problem into the question, and indicate that it happens from the command line. I'm 99% sure you'll just find that it's not actually in UTF-8... – Jon Skeet Jan 31 '14 at 19:44

0 Answers0