Apache NetBeans

Saturday August 17, 2019

LSP Client demo - (ba)sh language server

Below is a scenario by Jan Lahoda, the creator of LSP integration for Apache NetBeans, for how to integrate the bash language server with Apache NetBeans, including syntax highlighting.

Setting Up

  1. Install npm (and node.js). On Ubuntu, e.g., do "apt install npm", though something different will be needed on Mac OS X.

  2. Create a directory in which we are going to work, have a terminal opened in that directory.

  3. Install the bash-language-server:

    npm install bash-language-server

    On Mac OSX:

    npm install bash-language-server --unsafe-perm

    This will install the server into the current directory.

  4. Try the bash server:

    ./node_modules/bash-language-server/bin/main.js --help

    You should see something like this:

    Usage:
      bash-language-server start
      bash-language-server -h | --help
      bash-language-server -v | --version
  5. Create a NetBeans module. Create a File Type (Module Development/File Type), mime type: text/sh, file extension: sh

Syntax Coloring via TextMate

  1. Download the TextMate grammar file here, and put it alongside the newly created DataObject:

    https://raw.githubusercontent.com/microsoft/vscode/master/extensions/shellscript/syntaxes/shell-unix-bash.tmLanguage.json

  2. Add "TextMate Lexer" as a dependency of the module.

  3. Into the DataObject add this annotation:

    @GrammarRegistration(grammar="shell-unix-bash.tmLanguage.json", mimeType="text/sh")

    GrammarRegistration is:

    import org.netbeans.modules.textmate.lexer.api.GrammarRegistration;

This should lead to syntax highlighted source for .sh bash files taken from the TextMate grammar file.

Language Support via the Language Server

Next, we need to add language support using the language server.

  1. Add "LSP Client" and "MIME Lookup API" as dependencies of the module.

  2. Create a new class, ShellClient, in the module, put this into it, (replacing "<path-to-bash-language-server>" with the absolute path to "node_modules/bash-language-server"):

    import java.io.IOException;
    import org.netbeans.api.editor.mimelookup.MimeRegistration;
    import org.netbeans.modules.lsp.client.spi.LanguageServerProvider;
    import org.openide.util.Exceptions;
    import org.openide.util.Lookup;
    
    @MimeRegistration(mimeType="text/sh", service=LanguageServerProvider.class)
    public class ShellClient implements LanguageServerProvider {
    
       @Override
       public LanguageServerDescription startServer(Lookup lkp) {
           try {
               Process p = new ProcessBuilder("<path-to-bash-language-server>/bin/main.js", "start").start();
               return LanguageServerDescription.create(p.getInputStream(), p.getOutputStream(), p);
           } catch (IOException ex) {
               Exceptions.printStackTrace(ex);
               return null;
           }
       }
    
    }

    You may need to explicitly call node in the above code, i.e., as follows:

    Process p = new ProcessBuilder(
            "/usr/local/bin/node", 
            "<path-to-bash-language-server>/bin/main.js", 
            "start").start();
  3. Build and start the module.

Caveat: the language server is started only for files that are inside a project, so create (any) new project, and inside the project, put a shell file. E.g. copy "bin/netbeans" as "test.sh" into the project. Open it in the editor - there should be syntax highlighting, Navigator, and code completion should show something, etc.

Tuesday August 06, 2019

Why Does Apache NetBeans Need Its Own Parsers?

A question was asked on the Apache NetBeans mailing list: "I was just curious about the theoretical aspect of parsing. Isn't there a unified parsing API, using ANTLR/lex/yacc which can parse any language given a grammar for it? Why do we use a different parsing implementation (like the Graal JS parser in this instance) when a unified approach will help us support lots of languages easily?"

Tim Boudreau, involved in NetBeans from its earliest hours, responds, in the thread linked above:

First, in an IDE, you are *never* just "parsing". You are doing *a lot* with the results of the parse. An IDE doesn't have to just parse one file; it must also understand the context of the project that file lives in; how it relates to other files and those files interdependencies; multiple versions of languages; and the fact that the results of a parse do not map cleanly to a bunch of stuff an IDE would show you that would be useful. For example, say the caret is in a java method, and you want to find all other methods that call the one you're in and show the user a list of them. The amount of work that has to happen to answer that question is very, very large. To do that quickly enough to be useful, you need to do it ahead of time and have a bunch of indexing and caching software behind the scenes (all of which must be adapted to whatever the parser provides) so you can look it up when you need it. In short, a parser is kind of like a toilet seat by itself. You don't want to use it without a whole lot of plumbing attached to it.

Second, while there are tools like ANTLR (version 4 of which is awesome, by the way), there is still a lot of code you have to write to interact with the results of a parse to do something useful beyond syntax coloring in an IDE. One of my side projects is tooling for NetBeans that *do* let you take an ANTLR grammar and auto generate a lot of the features a language plugin should have. Even with that almost completely declarative, you wind up needing a lot of code. One of the languages I'm testing it with is a simple language called YASL which lets you define javascript-like schemas with validation constraints (e.g., this field is a string, but it must be at least 7 characters and match this pattern; this is an integer number but it must be > 1 and less than 1000 - that sort of thing). All the parsing goodness in the world won't write hints that notice that, say, the maximum is less than the minimum in an integer constraint and offer to swap them. Someone has to write that by hand.

Third, in an IDE with a 20 year history, a lot of parser generating technologies have come and gone - javacc, javacup, ANTLR, and good old hand-written lexers and parsers. Unifying them all would be an enormous amount of work, would break a lot of code that works just fine, and the end result would be - stuff we've already got, that already works, just with one-parser-generator-to-rule-them-all underneath. Other than prettiness, I don't know what problem that solves.

So, all of this is to say: We use different parsing implementations because parsing is just a tiny piece of supporting a language, so it wouldn't make the hard parts easier enough to be worth it. And there will be new cool parser-generating technologies that come along, and it's good to be able to use them, rather than be married to one-parser-generator-to-rule-them-all and have this conversation again, when they come along.

Thursday July 25, 2019

PHP 7.4 Support

Hi all. Today, we will briefly show you about PHP7.4 support which will be available in the next NetBeans version i.e. NetBeans 11.2.

First of all, I strongly hope that new features are tested by PHP users before NetBeans 11.2 is released because there should be bugs. Definitely, we need your help! If you are interested in them, please test it. You can download a dev version here. Then, we could merge new changes quickly thanks to our committer Tomas Mysik. Thanks a lot for your review, Tomas!

PHP 7.4 Support

To enable it, you have to set PHP 7.4 as the PHP version of your PHP project. (Right-click your project node, click Project Properties.)

NetBeans provides support for the new syntaxes for PHP 7.4.

Null Coalescing Assignment Operator

php74-null-coalescing-assignment-operator

Spread Operator in Array Expression

php74-spread-operator-in-array-expression

Numeric Literal Separator

php74-numeric-literal-separator

Typed Properties 2.0

Arrow Functions 2.0

php74-arrow-functions-2.0

New Hints

Suggestion for converting a simple closure to an arrow function

php7.4-convert-closure-to-arrow-function

Suggestion for using combined assignment operators

php74-suggest-using-combined-assignment-operators

Of course, code completion, formatting, go to declaration, and mark occurrence features for the above syntaxes should also be fixed.

That's all for today. As always, please test it. You can download a development version from Jenkins Build. If you find some issues or enhancements, please report them to JIRA with your exact steps to reproduce them. (Components: php - Editor). Thanks.

Monday July 22, 2019

[ANNOUNCE] Apache NetBeans 11.1 Released

The Apache NetBeans team is pleased to announce the release of Apache NetBeans 11.1. Apache NetBeans is a full IDE for Java SE, Java EE, PHP and JavaScript development with some Groovy language support.

Apache NetBeans 11.1 is the first Apache NetBeans release outside the Apache Incubator and the first release of the new quarterly release cycle. The LTS release of the Apache NetBeans 11 cycle is Apache NetBeans 11.0. The 11.1 release has not been as heavily tested as the LTS release. Use 11.1 to access the latest features and to provide feedback for the next LTS release, scheduled for April 2020.

New & noteworthy features of the 11.1 release:

https://netbeans.apache.org/download/nb111/index.html

Downloads:

https://netbeans.apache.org/download/nb111/nb111.html

Feel free to share the good news!

Monday June 10, 2019

Apache NetBeans, OpenJFX, and AdoptOpenJDK

Check out a great series of articles on a killer combination, by Chris Luff—Apache NetBeans, OpenJFX, and AdoptOpenJDK.

In part one you see how to get a modular JavaFX application built and running from NetBeans. In part two, you look at generating, from Maven, a runtime to execute the application. In part 3, you learn about the distribution of the new application.

Here are the three parts:

Thursday April 25, 2019

[ANNOUNCE] Apache NetBeans Has Graduated!

We have graduated from the Apache Incubator and we are now a top level Apache project at The Apache Software Foundation (ASF).

"Being part of the ASF means that NetBeans is now not only free and Open Source software: it is also, uniquely, and for the first time, part of a foundation specifically focused on enabling open governance," said Geertjan Wielenga, Vice President of Apache NetBeans. "Every contributor to the project now has equal say over the roadmap and direction of NetBeans. That is a new and historic step and the community has been ready for this for a very long time. Thanks to the strong stewardship of NetBeans in Sun Microsystems and Oracle, Apache NetBeans is now ready for the next phase in its development and we welcome everyone to participate as equals as we move forward."

The above is from the official Apache press release, all of which can be read here:

https://blogs.apache.org/foundation/entry/the-apache-software-foundation-announces51

Friday April 05, 2019

[ANNOUNCE] Apache NetBeans (incubating) 11.0 Released

The Apache NetBeans team is proud to announce the release of Apache NetBeans (incubating) 11.0.

Apache NetBeans (incubating) 11.0 constitutes all clusters in the Apache NetBeans Git repo, which together provide the NetBeans Platform (i.e., the underlying application framework), as well as all the modules that provide the Java SE, Java EE, PHP, JavaScript and Groovy features of Apache NetBeans.

In short, Apache NetBeans (incubating) 11.0 is a full IDE for Java SE, Java EE, PHP and JavaScript development with some Groovy language support.

Read more on our download page:

https://netbeans.apache.org/download/nb110/nb110.html

New & Noteworthy features of the 11.0 Release:

https://netbeans.apache.org/download/nb110/index.html

Friday February 01, 2019

Restructuring of Project Templates in Apache NetBeans

There's been lots of discussion in the Apache NetBeans community about how best to express the fact that Apache Maven and Gradle are more modern choices to be aware of than Apache Ant, while at the same time not implying that there's anything wrong with using Apache Ant.

Here's what we seem to have reached consensus around, i.e., move all Ant-based project templates into a separate Ant-specific folder, while putting the other two build systems higher and therefore more prominently in the list:

With the above, someone is less likely to simply go to the no-longer-existing Java category and then end up with an Ant-based project, without thinking about it. By default, the user of Apache NetBeans is now encouraged to consider Apache Maven and Gradle first. The old Ant-related categories are still there, so as not to confuse anyone completely, just structured within a lower ranked "Java with Ant" category. The above also solves the discussion re "Java EE", i.e., here the idea, from discussions, is to name the category "Java Enterprise".

At startup, all categories are closed, i.e., none is more prominent initially than any other.

An objection one could have is that, if you're a complete Java newbie, you won't know what Maven, Gradle, or Ant are. Well, that has always been the case and NetBeans has artificially hidden that choice by having a category simply named "Java", which then resulted in everyone ending up with Ant-based projects. To turn that around and have a category simply named "Java" that results in Maven-based projects is probably not right either, i.e., a careful balance needs to be struck.

Hoping that all factions in this lengthy discussion are relatively satisfied with this approach. :-)

Issue: https://issues.apache.org/jira/browse/NETBEANS-2040

Pull request: https://github.com/apache/incubator-netbeans/pull/1115

Monday January 28, 2019

Enterprise Cluster Integrated into Apache NetBeans

Hurray, the 'enterprise' cluster, constituting all the modules in Apache NetBeans GitHub that provide features for Java/Jakarta EE development, provided in the 2nd Oracle donation of NetBeans to Apache, has been integrated into the daily builds.

Now, for the first time, out of the box, you'll have the support that was part of NetBeans IDE 8.2 for Java EE development directly available in Apache NetBeans, that is, without you needing to install any plugins.

However, aside from the point that this means we do not yet have Java EE 8 support, since 8.2 did not (could not, because of being released some time prior to Java EE 8) have support for Java EE 8, another question now presents itself—whether we really want to have two categories in the New Project dialog, one named "Java EE" and the other named "Java Web", as shown below, with the former containing project types relating to EJBs and EARs, which are not (should not) be very current anymore, as shown below in the screenshots.

My suggestion would be to either relabel the above to "Modern Java EE" and "Vintage Java EE". (I like the word "Vintage", which I've learned about from JUnit, i.e., that's how they refer to JUnit 4.) Once there is Java EE 8 support, we could use the name "Jakarta" instead of "Modern Java EE". Or, maybe the EJB and EAR support should simply be removed?

Sunday January 27, 2019

Junit 5, Apache Ant, and Apache NetBeans

Junit 5 is, architecturally, so different to previous versions, that it should really be called Jupiter, instead. However, this is not a problem when you're using Maven, since Maven resolves all transitive dependencies for you, and is supported in that way from Apache NetBeans 10 onwards. Not so with Apache Ant, of course, where you need to set each and every JAR you need on a classpath of one form or another.

That is not a pretty picture in the end, when compared to JUnit 4, where you had just that JAR, plus Hamcrest. With JUnit 5, you need, in addition to junit-jupiter-api, junit-jupiter-params, and junit-jupiter-engine, to also declare the transitive dependency apiguardian-api, while in the case of Apache Ant, you need to deal with the JUnitLauncher, if you want to make use of the new junitlauncher Ant task, in addition to four other JARs, which need to be on Ant's classpath, as explained here.

An alternative approach is to use org.junit.platform.console.ConsoleLauncher, as shown here, which looks like this in my build.xml, i.e., it is named test, so that it will run automatically at the end of the test run when the Test Project action is invoked:

<target name="test" depends="compile-test,-pre-test-run">
    <java dir="${work.dir}" 
          classpath="${run.test.classpath}"  
          classname="org.junit.platform.console.ConsoleLauncher">
        <arg value="--scan-classpath"/>
        <arg line="--reports-dir build/test/results"/>
    </java>
    <junitreport todir="build/test/results">
        <fileset dir="build/test/results">
            <include name="TEST-*.xml"/>
        </fileset>
        <report format="frames" todir="build/test/results/html"/>
    </junitreport>
</target>

The above means that the JUnit tasks set by default in the build-impl.xml file will simply fail silently, since I don't have JUnit 4 on my classpath. At the end of the process, the above will be run, org.junit.platform.console.ConsoleLauncher will be found on my classpath, and then the JUnit 5 tests will be run.

What is the advantage of the above over using JUnitLauncher? Well, JUnitLauncher has requirements relating to Ant's path, which has advantages too, of course, i.e., simply set everything up once (which can also be done inside Apache NetBeans, in the Ant tab in the Options window). But, for right now, I'd prefer to work with just one path, i.e., the application's path.

Another downside is that, so far, the above solution doesn't integrate with the Test Results window, though it does produce some nice reports via the junitreport task above, in the build folder.

The key problem seems to me to be that the JUnit Ant task no longer exists in JUnit 5, which was for Ant-based projects the basis of the integration with the Test Results window in Apache NetBeans. If the JUnit task could continue to be used, in whatever way, that would solve a lot of the problems, though the question of the many JARs needed on the classpath would remain. Maybe library providers should reach out to tools providers when putting these kinds of new solutions together, since the only reason that JUnit 5 now works with Maven in Apache NetBeans is that Surefire is used, i.e., in the case of Maven the completely new approach JUnit has taken can simply be avoided there. Here is some relevant discussion in Apache NetBeans GitHub, and the Launcher API looks interesting.

Probably the best solution for Ant users in Apache NetBeans would be to be able to continue to use JUnit 4, rather than JUnit 5, since the latter is a total nightmare to set up in the context of Ant, as described above. In the world of JUnit, "vintage" is the cool name they have for "legacy", and if you're using Ant at all, you're probably best described as "vintage" and hence only having support for JUnit 4 is not a big deal for you. However, not sure at all how that would work, we'd need to investigate how/if when JUnit tests are added to Maven projects, JUnit 5 tests and dependencies would be set, while when adding JUnit tests to Ant projects JUnit 4 tests and dependencies would be set.

Thursday January 24, 2019

Master Your Scripting Skills with the New Tutorial!

Enhanced scripting tutorial has just become part of Apache NetBeans documentation. It contains various examples showing how to communicate from Java with JavaScript, Python and other languages. The following topics are covered:

While the primary use-case for this enhanced scripting API is to simplify usage of scripting languages in NetBeans based applications, the API itself is standalone and can be used outside of NetBeans in any project. We are working on making it available in the Maven central repository.

Read more in the online tutorial.

Thursday December 27, 2018

[ANNOUNCE] Apache NetBeans (incubating) 10.0 Released

The Apache NetBeans team is proud to announce the release of Apache NetBeans (incubating) 10.0.

Apache NetBeans (incubating) 10.0 constitutes all but the enterprise cluster in the Apache NetBeans Git repo, which together provide the NetBeans Platform (i.e., the underlying application framework), as well as all the modules that provide the Java SE, PHP, JavaScript and Groovy features of Apache NetBeans.

In short, Apache NetBeans (incubating) 10.0 is a full IDE for Java SE, PHP and JavaScript development with some Groovy language support.

Read more on our download page:

https://netbeans.apache.org/download/nb100/nb100.html

New & Noteworthy features of the 10.0 Release:

https://cwiki.apache.org/confluence/display/NETBEANS/Apache+NetBeans+10.0+New+and+Noteworthy

See the below for the donation status of features that have not been donated or included in Apache builds yet, i.e., are not part of Apache NetBeans (incubating) 10.0, e.g., features for working with C/C++, and more:

https://cwiki.apache.org/confluence/display/NETBEANS/Apache+Transition

Work is being done on bringing netbeans.org to Apache. In the meantime, refer to the below for all details related to Apache NetBeans:

https://netbeans.apache.org/

Wednesday November 07, 2018
Tuesday October 23, 2018

Duke Choice Award 2018 for Apache NetBeans

During Oracle Open World 2018, Apache NetBeans was awarded a Duke's Choice Award, recognizing its innovation and the hard and dedicated work involved in moving NetBeans from Oracle to Apache.

A crowd of Apache NetBeans community members received the award on the stage from Georges Saab, VP of the Java Platform at Oracle.

Wednesday October 17, 2018

Apache NetBeans at Oracle Code One 2018

  • Saturday, Oct 20, 19:00 p.m. | Thirsty Bear, 661 Howard Street
    Informal hangout (i.e., buy your own beer) with Apache NetBeans PPMC, committers, and community!

  • Sunday, Oct 21, 11:00 a.m. | Bike Ride
    Go here for details: https://blog.idrsolutions.com/2018/09/open-invitation-to-bike-ride-at-oracle-codeone/.

  • Monday, Oct 22, 1:30 p.m. - 2:15 p.m. | Moscone West - Room 2016
    Title: Machine Learning for Software Developers in 45 Minutes [DEV5090]
    Speakers: Zoran Sevarac, Frank Greco

  • Monday, Oct 22, 1:30 p.m. - 2:15 p.m. | Moscone West - Room 2022
    Title: Back from the Ashes: eFX/JavaFX Applications Made Simple [DEV5406]
    Speakers: Sven Reimers, Florian Vogler

  • Monday, Oct 22, 2:30 p.m. - 3:15 p.m. | Moscone West - Room 2018
    Title: Exploring Java Heap Dumps [DEV5262]
    Speakers: Ryan Cuprak

  • Monday, Oct 22, 7:30 p.m. - 8:15 p.m. | Moscone West - Room 2005
    Title: Deep Learning for Application Performance Optimization [BOF4967]
    Speakers: Zoran Sevarac

  • Monday, Oct 22, 8:30 p.m. - 9:15 p.m. | Moscone West - Room 2009
    Title: Hacking the NetBeans IDE [BOF4760]
    Speakers: Mark Stephens, Developer, Bethan Palmer

  • Tuesday, Oct 23, 7:30 p.m. - 8:15 p.m. | Moscone West - Room 2010
    Title: Writing Better Code (Faster) in the Apache NetBeans IDE [BOF4759]
    Speakers: Mark Stephens, Developer, Bethan Palmer

  • Tuesday, Oct 23, 7:30 p.m. - 8:15 p.m. | Moscone West - Room 2014
    Title: Got a Gig Teaching Java? You Should Be Using Apache NetBeans in the Classroom [BOF4820]
    Speakers: Kenneth Fogel, Instructor, Concordia University

  • Wednesday, Oct 24, 2:30 p.m. - 3:15 p.m. | Moscone West - Room 2016
    Title: Bridging Swing and JavaFX on an Enterprise Scale [DEV6080]
    Speakers: Sven Reimers, José Pereda

  • Wednesday, Oct 24, 9:00 a.m. - 9:45 a.m. | Moscone West - Room 2010
    Title: Java Debugging Tips [DEV4512]
    Speakers: Martin Skarsaune

  • Wednesday, Oct 24, 2:45 p.m. - 4:45 p.m. | Moscone West - Room 2001A (HOL)
    Title: Lambda Programming Laboratory - BYOL [HOL6006]
    Speakers: Jeff Dinkins, Stuart Marks, Maurice Naftalin, José Paumard

  • Thursday, Oct 25, 09:00 AM - 11:00 AM | Moscone West - Overlook 2A (HOL)
    Title: Jakarta EE Hands-on Lab - BYOL [HOL4852]
    Speakers: David Heffelfinger, Bob Larsen

Calendar

Search

Hot Blogs (today's hits)

Tag Cloud

Categories

Feeds

Links

Navigation