Over a million developers have joined DZone.

JCite Support in NetBeans IDE

· Java Zone

Learn more about the advantages of moving from a monolithic to microservices architecture.  Brought to you in partnership with IBM.

With JCite, you ensure that two sources are synchronized with each other. In my case, I'm interested in synchronizing the code referenced in tutorials I write with Java code in sample applications. I learned about all the things involved with JCite at Devoxx, from the guy who created JCite, Peter Arrenbrecht.

Simply put, in a template of a tutorial I have this, in the place where I'd like a snippet of code to be:


Then, in the class referred to above, I have the snippet I need surrounded as follows:

// ---fragment
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    String s = text.getText();
    s = s.toUpperCase();
// ---fragment

Then I run the JCite executable, with the arguments -i (input, i.e., the template file), -o (output, i.e., the actual tutorial in the actual folder where I'll check it into the repository), and -sp (source path, i.e., the path to the "src" folder in the sample project where the code snippet above is found).

I've created a small plugin for NetBeans IDE that automates most of this:

What you see above is a new type of file, i.e., with a "jcite" extension, which has specific properties shown in the Properties window, which opens in the HTML editor, and which has a specific menu item for running JCite, using the properties in the Properties window.

Now I'm working on code completion for the placeholder in the template file, which will let you complete the path to the file you're referencing and you'll also be able to use a hyperlink to open that file:



From Idea to Application gives you the architecture to quickly build, manage and run a range of applications (web, mobile, big data, new smart devices, etc.) on an open-standard, cloud-based platform. See why developers are using IBM Bluemix. Brought to you in partnership with IBM.


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}