Java syntax highliting

Topics: User Forum
Nov 2, 2009 at 11:17 AM


Is there a downloadable xml file that contains Java syntax for ScintillaNet?

I don't want to use C# syntax for java, because it's similar but not the same (for example it highlights the keyword "string").

Thank you in advance for your answers. :)

Nov 2, 2009 at 11:53 AM
Edited Nov 2, 2009 at 11:55 AM

I guess you have to use cpp Lexer and define your own Configuration File.

If you don't want to highlight the keyword "string" so remove it from the configurations Keywordlist.

€dit: Look here

Nov 2, 2009 at 3:40 PM

Thank you for your answer.

Is there an already defined Configuration File that I can download? Or I have to make it from scratch?

Thank you again!

Nov 2, 2009 at 7:13 PM

The closest to Java is c#. You can get it here

Nov 3, 2009 at 8:06 AM

Thank you! I'll edit this file, and if I finish it I'll post it here! :)


Nov 3, 2009 at 5:31 PM

OK, I think I finished 90% of editing the cs.xml in java.xml.

How can I can test it now? I mean, which properties of ScintillaNet object I have to set to use the syntax of this file?

Thank you again for your patience and help! :D

Nov 3, 2009 at 5:46 PM

I'm assuming you changed the language name to Java like so?

<Language Name="Java">
To make ScintillaNet use the new file you need to set the ConfigurationManager.Language to "java" and point ConfigurationManager.CustomLocation to the file path of java.xml. Both of these can either be done by the Windows Form designer or in code.

Nov 3, 2009 at 6:27 PM

I did exactly like you said, but I don't get syntax highliting and automatic indentation.

I also tried to put in my custom location directory cs.xml and default.xml, but if I set ConfigurationManager.Language to "cs" or to "default", I get an exception of file not found. What I'm doing wrong?


Nov 3, 2009 at 8:06 PM

Send me a small example project and I'll take a look:


Nov 4, 2009 at 4:54 PM

K1kk0z90 you were oh so close. The changes I made to get it working:

In the <Lexer> element I put in a LexerName="cpp". The reason the cs language doesn't have this is because this is a "known" language and ScintillaNet sets the cpp lexer automatically. Looking back on it that was a poor decision as it makes things confusing. The 2nd change I made was getting rid of the default.xml file. It really isn't needed and was interfering with the built in defaults. Instead I put all the styles that are defined for the cpp lexer within java.xml. You can find the list of defined styles here.

Nov 4, 2009 at 5:46 PM

Thank you very much for your help! :D

These days I'm going to check if Java syntax of java.xml is really finished (probably I'm currently missing some keywords). Then I'll post this file here to contribute to this great project!