Friday Mar 13, 2015

Royal Netherlands Navy on NetBeans

A few days ago I had the opportunity to visit the headquarters of the Royal Netherlands Navy in Den Helder, which is in the tip of the most northern part of the Netherlands. That's where naval ships such as the following are managed:

The various military components on naval ships like the above are controlled by programs coded via an MDA (Model Driven Architecture) methodology based on the Shlaer-Mellor methodology, comparable to Executable UML. An in-house Shlaer-Mellor MDA and an ASL implementation are used for coding. The models and the ASL are compiled by an in-house compiler into C code, which is then compiled into an executable via a C compiler.

An in-house IDE has been developed for the in-house implementation of the Shlaer-Mellor/Executable UML methodology, by SATS Den Helder, which is part of the Defence Material Organisation, for the approximately 40 in-house internal developers who are working with these modeling methodologies. The IDE is used for modeling, as well as for the related ASL code, providing the rich features expected of a modern IDE, in addition to the modelling features you see below, this includes a full-blown ASL editor, with syntax coloring, code completion, refactoring, find usages, code navigation, compilation, and diffing of models.

Guess what that in-house IDE, specifically created for those 40 developers, looks like? Click to enlarge it:

What you see is a complete development environment created on NetBeans for the usage of the Shlaer-Mellor/Executable UML methodology together with the in-house implementation of ASL, created with the key idioms that NetBeans provides, e.g., Module, TopComponent, Lookup, etc. However, there's no project system, because each application is stored in a single XML file. Everything you see above is extrapolated from a single XML file.

The developers told me they'd never have created the above application without NetBeans, since it provides an enormous amount of plumbing, especially the window system that you see above. The Visual Library is used, for the modeling, as well as JFreeChart (which might potentially become JavaFX). The immediate professional appearance that an application on NetBeans gains out of the box was a key reason for using it.

Prior to using the NetBeans Platform as the basis of this application, extensive analysis was done in comparing it with Eclipse RCP. Clearly, NetBeans won. Other applications have been developed, while others are being started from scratch, by the Royal Netherlands Navy on the NetBeans Platform. Being able to share modules between different applications is a big win and that's something that the development team is leveraging as they develop more applications that do similar things. I have some more screenshots of these that I'll share in the coming days.

Thursday Mar 12, 2015

Ctrl-G = Go to Line | Go to Bookmark

A super hidden NetBeans feature is the fact that you can jump to bookmarks from the "Go to Line" dialog, as this quick screencast shows:

Wednesday Mar 11, 2015

Ignored Files in NetBeans IDE

In the Options window, within Miscellaneous | Files, there's this cryptic text field:

How to understand it and how to, for example, enable all XML files to be ignored, i.e., not shown in the Projects window and Files window?

The above is a regular expression, here is an explanation of the characters you see being used above:

Character Description
| Or.
^ Matches all file or directory names beginning with the subsequent characters.
$ Matches all file or directory names ending with the preceding characters.
\ Escape character. Necessary if you want to match to a period (.) or other special character.         
.* Wildcard.

For example, if you want to ignore all files with the .bak extension, add this:

\.bak$

That means you now have this line, with the addition in bold below:

^(CVS|SCCS|vssver.?\.scc|#.*#|%.*%|_svn)$|\.bak$|~$|^\.(?!(htaccess|git.+|hgignore)$).*$ 

 Similarly, if you don't want to see XML files, change bak to XML, as shown below:

^(CVS|SCCS|vssver.?\.scc|#.*#|%.*%|_svn)$|\.xml$|~$|^\.(?!(htaccess|git.+|hgignore)$).*$ 

However, notice what happens in the Projects window and Files window for Maven projects when XML files are ignored, via the above setting.

This is the default situation, i.e., everything is shown exactly as it is when you make no changes to the ignored files definition: 

Here, however, XML files have been excluded:

What you see is that the "Project Files" node is excluded from the ignored files definition. While all the XML files are ignored, i.e., hidden, throughout the project, both in the Projects window and in the Files window, the Project Files node remains showing the XML files. Not sure whether to see this as a bug or not. 

Tuesday Mar 10, 2015

Out of the Box Free Java PDF Viewers

Here's a really handy tip for you if you're at NASA, Boeing, etc, creating large software on top of the NetBeans Platform—at some stage you probably need a PDF viewer of some kind as part of your application. Before trying to figure out how to create and integrate a PDF viewer, simply go here:

http://plugins.netbeans.org/plugin/52568

That brings you here:

https://www.idrsolutions.com/open-fx/downloads/

And then a few clicks later you have JARs, and source code, that integrate three different kinds of PDF viewers into your application. The plugin gives you a choice of three different PDF viewers, together with a window named "PDFTopComponent". Hence, if you don't want to do anything with the sources, simply bundle the JARs and then refer to the PDFTopComponent in your own code:

TopComponent tc;
     //this gives me a new window each time
     tc=new PDFDisplayTopComponent(pathToFile,viewerType);
     tc.open();
     tc.requestActive();  

The three different types of viewer are shown below, as well as the fact that they even render music notation very well.

These are really great and IDRSolutions have done a wonderful job making these available.

Monday Mar 09, 2015

NetBeans Day in Germany: 16 March, 2015

A few months ago, in December 2014, the Oracle office in Munich, Germany, was used for the first time to host a NetBeans Day. It was a big success. At that event, we immediately decided we wanted to have another day just like it and soon!

It's going to be held on the 16th of March, it is already fully booked, though you can sign up on the waiting list.

The agenda is pretty cool, split in two tracks in the afternoon:

09:00 - 09:15 Welcome to NetBeans Day, Geertjan Wielenga, Peter Doschkinow, Toni Epple
09:15 - 10:15 HTML 5 + Java FX mit NetBeans, Adam Bien
10:15 - 10:45 Coffee Break
10:45 - 11:45 Java 8 - the other stuff (beyond lambdas), Kirk Pepperdine
11:50 - 12:50 A Sneak Peak into JDK 9 , Dalibor Topic
12:50 - 13:50 Lunch Break

Track 1 Extending NetBeans
13:50 - 14:50 NetBeans Platform and JavaFX, Gail and Paul Anderson
15:00 - 15:45 Writing Plugins for the IDE, Benno Markiewicz
15:45 - 16:05 Coffee Break
16:05 - 17:05 Modern Web Development with NetBeans, Thomas Kruse
17:10 - 18:00 NetBeans Platform Show & Tell, Sven, Gail, Paul, etc

Track 2 Using NetBeans
13:50 - 14:50 "Kaffee und Kuchen" - Home-Control mit Java Embedded auf dem Raspberry Pi, Jens Deters
15:00 - 15:45 Teaching with NetBeans - Karsten Sitterberg, Geertjan Wielenga
15:45 - 16:05 Coffee Break
16:05 - 17:05 Running Java Everywhere with DukeScript and Bck2Brwsr, Jaroslav Tulach, Toni Epple
17:10 - 18:00 "Hello Oracle Developer Cloud Service!" Peter & Geertjan

Note: A special thanks to Paul and Gail, for coming all the way from the US for this event, they're the authors of the brilliant JavaFX Rich Client Programming on the NetBeans Platform.

Sunday Mar 08, 2015

Bach in NetBeans

Notice the "Play" and "Stop" buttons! All this is thanks to LilyPond. Yes, LilyPond generates MIDI files, as well as PDF files. Truly awesome. And the above actually works, I can generate and play Bach in NetBeans. 

The above was generated as described here:

A great resource: http://www.mutopiaproject.org

Saturday Mar 07, 2015

Happy Birthday, Java!

\header {
  title = \markup { \italic "Happy Birthday, Java!" }
}

\paper {
  indent = #0
}

\score {
  \new PianoStaff = "pianostaff" <<
    \new Staff = "right" \relative c'' {
      \clef "treble"
      \time 3/4
      \tempo "Quick and snappy" 4 = 160
       r2 c8 c
       a'4 g f
       g2 e4
       f r f
       g2 c,4
       a' b c
       g2 e8 e
       f4 e d
       c2. r2. \bar "|."
    }
    \addlyrics {
      Ha py birth -- day Ja va, 
      you are twen ty!
      For fun and for gain, 
      pub -- lic sta -- tic void main!
    } 
    \new Staff = "left" \relative c {
      \clef "bass"
       c4 <e g> <e g>
       f4 <a c> <a c>
       c,4 <e g> <e g>
       g,4 <b d> <b d>
       c4 <e g> <e g>
       f4 <a c> <a c>
       c,4 <e g> <e g>
       g,4 <b d> <b d>
       c4 <e g> <e g>
       c2. \bar "|."
    }
  >>
  \layout { }
  \midi { }
}

Friday Mar 06, 2015

Rendering Music Notation in PDF Files on the Java Desktop

It turns out to be pretty tricky to render music notation in PDF files in a Java desktop application. The upper part of the image below shows what Apache PDFBox makes of my PDF with music notation, below that you see the correct rendering in Acrobat PDF Reader:

Here's the PDFBox code for the above:

InputStream inputStream;
    try {
        inputStream = FileUtil.toFileObject(pathToPDFFile).getInputStream();
        SwingController controller = new SwingController();
        SwingViewBuilder factory = new SwingViewBuilder(controller);
        JPanel viewerComponentPanel = factory.buildViewerPanel();
        add(viewerComponentPanel, BorderLayout.CENTER);
        controller.openDocument(inputStream, "", "");
    } catch (FileNotFoundException ex) {
        Exceptions.printStackTrace(ex);
    }
}

Next, let's look at a JavaFX solution, provided by this blog entry:

Possibly I haven't used PDFBox or JPedal-technologies correctly and the problem isn't with these libraries but with my lack of understanding of how to apply them to this scenario. 

So, finally, not having found any other way of achieving my goal, I used LilyPondTool for JEdit:

The above is a PDF generated via LilyPond and rendered in NetBeans via an embedded "DockablePdfViewer", which is based on JPedal, which is also part of LilyPondTools. After adding LilyPondTools as a JAR to my project, as well as JEdit itself, together with quite a few other JARs, the only code I needed to provide myself, turned out to be the following, after a lot of trial and error, in my MultiViewElement:

jEdit.initSystemProperties();
jEdit.setProperty("options.lilytool.pdf.follow-caret", "true");
DockablePdfViewer dpv = new DockablePdfViewer();
dpv.setCurrentFile(pathToPDFFile);
dpv.refresh();
add(dpv, BorderLayout.CENTER);

A couple of sneaky tricks were needed to circumvent JEdit's own protocol for finding images:

@ServiceProvider(service = URLStreamHandlerFactory.class)
public class JEditResourceStreamHandlerFactory implements URLStreamHandlerFactory {
    @Override
    public URLStreamHandler createURLStreamHandler(String protocol) {
        if (protocol.equals("jeditresource")) {
            return new LilyPondToolHandler();
        }
        return null;
    }
    private static class LilyPondToolHandler extends URLStreamHandler {
        @Override
        protected URLConnection openConnection(URL u) throws IOException {
            return new LilyPondConnection(u);
        }
    }
    private static class LilyPondConnectionextends URLConnection {
        private ByteArrayInputStream is = null;
        public LilyPondConnection(URL url) throws UnsupportedEncodingException {
            super(url);
            String file = url.getPath().replace("/LilyPondTool.jar!/", "");
            Image image = ImageUtilities.loadImage(file);
            try {
                ByteArrayOutputStream os = new ByteArrayOutputStream();
                ImageIO.write((RenderedImage) image, "png", os);
                is = new ByteArrayInputStream(os.toByteArray());
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
        @Override
        public void connect() throws IOException {
        }
        @Override
        public InputStream getInputStream() throws IOException {
            return is;
        }
    }
}

At the end of the day, I can now display music notation in PDF files in NetBeans IDE. The dependency graph is a bit too impressive though and a lighter solution would be preferable:

One other problem is that not all of the JARs shown above are in a Maven repo, i.e., I have them in my local repo only. 

Since PDF music notation files can be rendered via LilyPond, the basis for a complete LilyPond integration for NetBeans is not inconceivable.

I'm working on that here:

https://github.com/GeertjanWielenga/NetLilyBeansPond

Thursday Mar 05, 2015

Free: Learn How To Use All 50 Java Keywords!

Kai Uwe Pel, who I met at NetBeans Day Netherlands recently, gave me a fantastic tip yesterday.

He told me about a great and free course that fills in any spaces you might have in your basic Java knowledge:

https://www.udemy.com/learn-how-to-use-all-50-java-keywords

When you go there and log in, for free, you have access to a wonderful starting point or, possibly, a place where you can remind yourself of the basic principles of Java. It won't teach you object orientation and Java programming in general, as Huw Collingbourne's course does so well, but certainly it is excellent in covering the specific thing it covers.

Of course, NetBeans is used from beginning to end:

A fantastic free resource! Get started with it today.

Tuesday Mar 03, 2015

Learn Java, For Real, Thoroughly, With Huw and NetBeans IDE

The two tools you need when learning Java are Huw Collingbourne and NetBeans IDE. Watch this quick screencast on why this is the case:

For this week only, i.e., until Tuesday next week, there's a massive discount:

https://www.udemy.com/java-programming-the-master-course/?couponCode=JAVANETBEANS

Once you buy the course (PayPal works brilliantly), you'll get this starting point with heaps of well structured lessons in bite size chunks:

You'll be a Java programmer before you're even aware of it!

Monday Mar 02, 2015

Transcript of "Free Open Source Tools" OTN Virtual Technology Session

The OTN Virtual Technology Sessions have now happened in two timezones, for the Americas and for EMEA. The final edition in the current series is for the APAC timezone, on March 4th, from 9:30 to 13.00 IST.

Read all about it here:

http://netbeans.dzone.com/articles/free-virtual-technology-summit

As you can see in the image above, while watching the pre-recorded screencasts, you can chat with moderators, who are generally the people involved in the making of the screencasts. I'm the one who made the screencast for "Free Open Source Tools for Maven, HTML5, IoT, and Java EE" and moderated the session. During the most recent one, for EMEA, there was quite some discussion, i.e., a lot of questions were asked while the screencast was being watched by quite a lot of people. Some wanted to see the transcript because a lot of info was shared. So, here it is! 

  • How much NetBeans costs? 
    It's free! Get it from netbeans.org -- free and open source.

  • Which plugin I need for using Maven in NetBeans? 
    Good question. No plugin needed. NetBeans natively supports Maven. No installation or configuration need.

  • What is "Internet of Things" doing here with JavaEE, Maven, and HTML5? I know internet is hugely connected with web applications but what is the specific reason here?
    Well, these are the key features of NetBeans -- it is a great tool for doing development for IoT, Java EE, Maven, and HTML5. That's why they're all included here, because NetBeans provides great tools for working with all of them, separately, or together.

  • It seems NetBeans is for more than just Java?
    Definitely! There's a special download bundle of NetBeans which is ONLY for doing HTML5 frontend development. All for free, which you can use together with or instead of Sublime or WebStorm. For free.

  • Your NetBeans looks faster and better than mine.
    That's because I'm using the "Dark Look and Feel Themes" plugin and because I have a very small version of NetBeans, which only contains HTML5 frontend tools, get it for free from netbeans.org/downloads.

  • Everything you mentioned so far is for free. Which products do we have to license?
    Nothing to license. All free. :-) Nothing in or with NetBeans is for any money at all, no licensing, whatever, etc. Free.

  • Bower, Node.js, Angular... what's going on here?! NetBeans has support for all of these? Even test coverage for JavaScript files?
    Yup, you're right, NetBeans is great.

  • Where can we find out more about all of this?
    https://netbeans.org/features/html5/index.html

  • At the bottom of your screen it seems you have a browser inside NetBeans?
    Yes, very useful feature -- an embedded browser. I use it all the time.

  • What about MongoDB? Does NetBeans support it?
    There's MongoDB plugins on the Plugin Portal: http://plugins.netbeans.org

  • Does NetBeans have a presence on social media?
    Yes! New tips and tricks every day at facebook.com/netbeans, twitter.com/netbeans, and many moves at the NetBeans YouTube channel.

  • Where are the NetBeans YouTube videos found?
    https://www.youtube.com/user/NetBeansVideos

  • Is NetBeans a good replacement for Eclipse?
    Definitely. The Maven integration in NetBeans is much better than in Eclipse. The HTML5 tools too. For Java EE, there's no better IDE than NetBeans. 

  • Is NetBeans fast?
    For me, it takes 9 seconds to start up the HTML5 distribution of NetBeans. No JDK required for this, only the JRE.

  • How much does the enterprise version of NetBeans cost?
    NetBeans is 100% free. If you ever find yourself giving anyone any money for NetBeans, you can be 100% that you're being ripped off. :-)

  • Can NetBeans be used as an infrastructure for applications, just like Eclipse RCP?
    Yes, definitely. NATO and Boeing and many other organizations use it exactly like that: https://platform.netbeans.org/screenshots.html

Sunday Mar 01, 2015

Why I Am Excited About JDK 8 Update 40

Doing JavaFX development? Take a look at the very clear performance enhancements in JDK 8 Update 40 (https://jdk8.java.net/download.html) by looking at a new EPUB plugin that's being worked on:

Saturday Feb 28, 2015

Handy HyperlinkProvider

NCX files are XML files with a specific file extension, "ncx", which are part of EPUB, and below you can see that when I hold down the Ctrl-key and move over a "src" attribute in an NCX file, a hyperlink appears, which when clicked opens the referenced file.

The hyperlink code is as follows:

@MimeRegistration(mimeType = "text/ncx+xml", service = HyperlinkProvider.class)
public class NcxHyperlinkProvider implements HyperlinkProvider {

    private static String SRC_IDENTIFIER = "src";
    private String identifier;
    private int targetStart;
    private int targetEnd;

    @Override
    public boolean isHyperlinkPoint(Document doc, int offset) {
        return verifyState(doc, offset);
    }

    public boolean verifyState(Document doc, int offset) {
        TokenHierarchy hi = TokenHierarchy.get(doc);
        TokenSequence<XMLTokenId> ts = hi.tokenSequence(XMLTokenId.language());
        ts.move(offset);
        ts.moveNext();
        Token<XMLTokenId> tok = ts.token();
        if (tok != null) {
            int tokOffset = ts.offset();
            switch (tok.id()) {
                case VALUE:
                    while (ts.movePrevious()) {
                        Token<XMLTokenId> prev = ts.token();
                        switch (prev.id()) {
                            case ARGUMENT:
                                if (SRC_IDENTIFIER.equals(prev.text().toString())) {
                                    identifier = tok.text().toString();
                                    targetStart = tokOffset;
                                    targetEnd = targetStart + tok.text().length();
                                    return true;
                                }
                            case OPERATOR:
                                continue;
                            case EOL:
                            case ERROR:
                            case WS:
                                continue;
                            default:
                                return false;
                        }
                    }
                    return false;
            }
            return false;
        }
        return false;
    }

    @Override
    public int[] getHyperlinkSpan(Document document, int offset) {
        if (verifyState(document, offset)) {
            return new int[]{targetStart, targetEnd};
        } else {
            return null;
        }
    }

    @Override
    public void performClickAction(Document doc, int offset) {
        identifier = identifier.replaceAll("\"", "");
        FileObject fo = Utilities.actionsGlobalContext().lookup(FileObject.class);
        String path = fo.getParent().getPath();
        File file = new File(path + "/" + identifier);
        if (file.exists() && file.isFile()) {
            try {
                DataObject.find(FileUtil.toFileObject(file)).getLookup().lookup(OpenCookie.class).open();
            } catch (DataObjectNotFoundException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    }

}

All the code: https://java.net/projects/epubopentoolbox/sources/epub/show/80/fosfor/fosfor-ncx.

Friday Feb 27, 2015

From Eclipse to NetBeans

It's kind of hard to tell the difference between the snippets of code below. But they come from two different tools, one of them is NetBeans and the other is Eclipse. I think it's irrelevant to say which is which since the rendering of the font of each is excellent. I'd happily work with font rendered by either of the two different tools below.

By default, the coloring, and other styling, of font in NetBeans looks different to how it looks in Eclipse. That's easy to solve, assuming you find this to be a problem, via this excellent addition to NetBeans:

https://github.com/Boris-de/eclipsecolors_for_netbeans.git

When switching from Eclipse to NetBeans, it certainly helps a lot if the project you're migrating uses Maven as its build system. Maven-based projects are automatically recognized by NetBeans. NetBeans understands that if a folder contains a 'pom.xml' file, it is a Maven project. Hence there's no import process needed. Instead, you can simply go to File | Open Project to open any folder containing a 'pom.xml' file into NetBeans as a Maven project.

Finally, you'll find this very useful, thanks to Benno Markiewicz, which lets you import Eclipse formatting files into NetBeans and use them to format your files:

http://plugins.netbeans.org/plugin/50877/eclipse-code-formatter-for-java

Thursday Feb 26, 2015

YouTube: Format Multiple Files in NetBeans IDE

When lines of code in various kinds of files, whether of the same type or different types, are misaligned, you can reformat them (using the formatting rules you have defined in the Options window or the default ones you get out of the box from NetBeans) all at the same time. Whether or not you're using a project, i.e., you could be working with individual files in the Favorites window, reformatting multiple files is easily done. Watch this quick screencast to see how:

Wednesday Feb 25, 2015

Free Open Source Tools for Maven, HTML5, IoT, and Java EE

I took part in another edition of the OTN Virtual Technology Day today. It started with being invited to contribute a screencast to the event, which I made especially for this occasionenabling me to think afresh about what it is exactly that makes NetBeans special and so I focused on Maven, HTML5, Internet of Things, and Java EEand then I also moderated the sessions live, i.e., answered questions that attendees asked while attending the session.

A week or two ago, the event happened in the Americas timezone and today it was the turn for EMEA. From 10.00 to 14.30 today, attendees in the Java track heard from a range of speakers, including Tori Wieldt, Bruno Borges, and Gerrit Grunwald. The "Free Open Source Tools" session looked as follows, click to enlarge, and notice some of the cool questions that were asked while attendees watched the screencast: 

There were several other questions after the above were asked, all really great and enthusiastic. Very nice to get the kind of feedback I'm seeing at these events. 

One more chance for attending the series of screencasts that constitute OTN Virtual Tech Days is for the APAC timezone–on 4 March–from 9:30 to 13:30 IST. Looking forward to seeing even more attendees there! 

The agenda can be viewed here: https://community.oracle.com/docs/DOC-894285

Tuesday Feb 24, 2015

From Sublime to NetBeans?

What if Sublime were to be less cool than you thought and what if NetBeans were to be faster than you've assumed it to be? Right-clicking on an HTML file on disk and then opening it into Sublime takes 1 second, while with NetBeans IDE 8.0.2, if you're using the small HTML5 & PHP distribution (which doesn't need the JDK, only the JRE) it takes 9 seconds. Is 8 seconds a very big deal? To me, it sounds like NetBeans is an IDE that is 8 seconds away from being as fast as an editor.

Sure, performance and speed is a lot more than startup time. It's also about how quickly and easily things open and how smoothly you can switch from one task to another. But even here NetBeans has made great strides over recent releases and there's useful plugins like the Sublime feature (in fact, on the NetBeans Plugin Portal there are currently 6 different Sublime plugins) and the One Click Open Sesame feature to make it even more editor-like. Below are two screenshots, on the left of each you see Sublime, on the right you see NetBeans. Click the images to enlarge them and, unless I'm very much mistaken, the difference between them is 8 seconds faster startup time for Sublime, versus heaps of integrated features (which surely are worth waiting 8 seconds for) in NetBeans.

If you haven't tried the small bundle of NetBeans, i.e., the bundle aimed specifically at frontend developers, i.e., the HTML5 & PHP bundle, go here to get it (all free):

https://netbeans.org/downloads/

One feature I really like in Sublime, and it is also in the JetBrains products, is the multicursor functionality. I.e., you can have more than one cursor, i.e., on multiple lines. Lets you select code in multiple lines and change them at the same time, like rectangular block selection but not limited to a block. Seems like an extremely cool feature to me. However, the question does arise how often one needs that feature versus, for example, code completion for AngularJS directives, with embedded AngularJS documentation, as well as cutting edge KnockoutJS features, and native integration with Git, Gulp, Grunt, Bower, Node.js, Cordova, SASS, LESS, Mocha, Karma, Protractor, and Selenium, as well as integration with the Chrome browser, a library of out-of-the-box samples, and heaps more.

If you're going to respond to this admittedly contentious blog entry, it would really help if you've recently, i.e., over the last 6 months, made heavy use of both Sublime and NetBeans.

Monday Feb 23, 2015

YouTube: Search Everywhere in NetBeans IDE

What do you do when you don't know how to do something in NetBeans IDE? Do you search through random menu items? Do you go to Google and StackOverflow and mailing lists? Do you search through tutorials? What do you do? In this short YouTube clip, you'll learn about a feature you probably didn't know about or might soon look at in a different way.

While making the above, I realized I need to work a bit more on the Key Promoter plugin since not everything of interest I do with the keyboard is currently shown in the toolbar, yet.

Sunday Feb 22, 2015

How to Quickly Create New Java Files

I was looking at the Quick Search field a few days ago with a programmer friend and we were also discussing the New File dialog and how clunky it is to find how to create new Java source files there. So I thought, why not integrate relevant templates from the New File dialog into the Quick Search field?

Here's the result, i.e., notice that when I type "java", I can see (for the first time thanks to this new plugin I created) various Java file templates are available which, when clicked below, cause the relevant New File dialog to appear, all filled out with the values of the currently selected project. If no project is selected, or a file within a project, a message appears informing you of that requirement, since Java files need to be created within projects.

Source code:

https://github.com/GeertjanWielenga/NewFileSearchProvider

Saturday Feb 21, 2015

Greenfoot and NetBeans (Part 2)

Recently I wrote about Greenfoot and NetBeans. Since then, Michael Kölling and his team have been working hard on simplifying the steps of moving a Greenfoot project to NetBeans. I tried out his simplified instructions today, with a build of a new release of Greenfoot, and found that in the previous blog entry, step 4 and 5 are no longer needed.

When you want to open a Greenfoot project into NetBeans, start by using the "Java Project with Existing Sources" wizard (in the New Project wizard, Ctrl-Shift-N) to import the project. For example, the "lunarlander" project, which comes with Greenfoot, looks as follows in NetBeans:

As described in the previous blog entry, you need to put "bluejcore.jar" and "greenfoot.jar" on the classpath of the project, as you can see above.

Next, right-click the project and choose Properties. In the Run tab of the Project Properties dialog, define the following (click to enlarge the screenshot below):

As you can see in the screenshot above, you need to the working directory to the root folder of the project. And, as you can also see above, you need to run "greenfoot.export.GreenfootScenarioMain" with three arguments, with no commas between them:

  • Scenario name.
  • Name of the world class (just the name, no .class extension).
  • Path to the 'greenfoot-labels' file from the Greenfoot installation (lib/english/greenfoot/greenfoot-labels).

Following the above steps, there's no need to create a properties file, which was defined in the previous blog entry, i.e., if the "greenfoot-labels" file is available.

Then run the project and you should see that it works perfectly, no need to fiddle with images and resources either, they're now found automatically:

About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« May 2015
SunMonTueWedThuFriSat
     
2
3
8
9
10
19
29
30
31
      
Today