- Netbeans Mac Os
- Netbeans For Mac Mojave
- Netbeans For Mac Osx
- Netbeans For Macbook Air
- Netbeans For Mac High Sierra
Apache NetBeans Fits the Pieces Together. Quickly and easily develop desktop, mobile, and web applications with Java, JavaScript, HTML5, PHP, C/C and more. Apache NetBeans is free and open source and is governed by the Apache Software Foundation. NetBeans For Java How To Install and Get Started with Java Programming (on Windows, Mac OS and Ubuntu). NetBeans IDE lets you quickly and easily develop Java desktop, mobile, and web applications, while also providing great tools for PHP and C/C developers. NetBeans for Mac. How to Install NetBeans on MacOS? NetBeans is a software development platform written in Java. It is an official IDE for Java 8 development. It was developed and released by Sun Microsystems which was later acquired by Oracle. NetBeans 8.2 was released on October 3, 2016. NetBeans is by definition, a Java application - write once, run anywhere. But, particularly with regard to the differences between the Macintosh UI and other platforms, providing an optimal user experience requires paying at least some attention to the expectations of users on a given platform.
In the past two articles you have seen how to customize your Java application so that it looks and feels more like a native Macintosh application when running on Mac OS X without changing the end user experience on other platforms. A combination of runtime properties and coding changes that targeted Mac OS X specific APIs made a big difference to that audience.
Recall that Mac OS X is a melding of two worlds. Hard core UNIX programmers can pop open a Terminal window and write their Java code using vi and compile and run it from the command line. There is, however, the more traditional Mac audience that interacts with their computer through a friendly UI that follows Apple Human Interface guidelines.
In this article, we look at deploying your Java application. The technical geek audience might be happy with running a class with a
main()
method from the command line but the wider audience expects a double-clickable icon that looks and acts like every other native application. In this article, we travel from one end of the spectrum to the other to broaden your potential user base.Although you should 'test everywhere', your build machine may not be a Mac. Fortunately, as you will see, a double-clickable Macintosh application is just a directory with some special contents and a name that ends with
.app
. Even on a Windows machine you should be able to modify your build script to package up a Mac-specific version of your application.Primitive Distributions
Because Mac OS X ships with J2SE 1.4.1 and J2SE 1.3.1, you can distribute your application as class files or jar files and - in theory - your customer could run your application from the Terminal application. We start with these models and quickly move to double-clickable jar files and shell scripts.
For this article, use the Java Sound Demo as the running example. Download and unzip the zip file. Inside the
JavaSoundDemo
directory you will find the source files inside of the src
subdirectory, a jar file, audio files, and html files that we will not use.Raw Class Files
As a developer, you don't think twice about compiling the source files and running the application using the command line. Compiling the eight files in the
src
directory generates fifty class files. You can then run the sample application from the command line like this.java JavaSound
The Java Sound Demo starts up. We haven't customized the application in any way so the menu appears at the top of the JFrame and not where Macintosh users expect. The application looks like this out of the box.
You have done this compile and run step so many times that you hardly think twice about it. Think of the least technical person you know and ask whether they would be likely to follow these steps to run your application if a competing application were easier to install and run.
This example demonstrates two separate areas of usability. Once we got the application up and running it looked good and ran fine. You would not, however, want to distribute an application to an end user this way. You would have to somehow bundle up the fifty class files for easy download and installation. You would then have to provide instructions for running the application using, in the case of Mac OS X, the Terminal application.
Jar Files
If you are going to have to package up the class files for distribution anyways, you may as well produce a jar file. And, if you are going to produce a jar file, it ought to be executable. In the case of the Java Sound Demo, the file
JavaSoundDemo.jar
is executable. Because Mac OS X ships with the Jar Launcher application, the end user needs only double click on the jar file and the application will launch.To make the jar file executable, the manifest must include the name of the Main class file. Unjar
JavaSoundDemo.jar
with the command jar xvj JavaSoundDemo.jar
. Here's the file META-INF/MANIFEST.MF
.Shell Scripts and Helper Applications
For larger or more complicated applications you are likely to have more than one jar file along with resource files. A common strategy for targeting multiple platforms is to include a batch file and a shell script. Choose the non-platform specific download from the NetBeans homepage. Word apps for mac. Inside of the bin subdirectory you will find applications for running NetBeans on a variety of platforms.
The shell script
runide.sh
can be run from the command line like this.sh runide.sh -jdkhome /Library/Java/Home
The NetBeans IDE starts up with this decidedly non-Mac OS X look and feel.
You could, of course, modify the shell script to modify this look and feel, but the NetBeans developers decided on a different approach. Even though the typical NetBeans audience member is technically competent, there should be a friendlier way to start the IDE. They have created a native Mac OS X application called
NetBeansLauncher
.The version of
NetBeansLauncher
that is included in the generic NetBeans download is a good next step. You will see how the team took it farther in the next section. On a Mac OS X computer you can double click on the macosx_launcher.dmg
file inside of the bin
directory. This is a disk image. Drag the NetBeansLauncher
from the expanded disk image back into the bin
directory. Now double click on the NetBeansLauncher
. The ReadMe file that was also in the disk image provides the following information about usage.When launched for the first time, NetBeansLauncher needs to find NetBeans root directory. First it looks into NetBeansLauncher.app itself. If it does not find NetBeans root directory there user must specify NetBeans root directory manually.
For this download, the first time the user starts up the
NetBeansLauncher
, they need to navigate to the netbeans
directory. After that, double clicking on the NetBeansLauncher
starts up the NetBeans IDE as if it were any other native Mac OS X application.First Class Mac OS X Applications
If you download the Mac OS X disk image from the NetBeans distribution and mount it you may be surprised at the simplicity of what you find. Unlike the complex structure visible in the other distributions, you will see five files with documentation and a single application. To install, you can move this
NetBeansLauncher
application anywhere on your hard drive. Double click on it and the NetBeans IDE starts right up.This is the experience that is expected on Mac OS X. The package structure and complexity is hidden from the user and they can't accidentally move a file that renders the IDE unusable. In this section we'll look more closely at the package structure and how to create a Mac OS X application whether or not our build machine is a Mac.
Packages in Mac OS X
Netbeans Mac Os
Consider again the sentence from the
NetBeansLauncher
instructions that says in order to locate the NetBeans root directory, 'First it looks into NetBeansLauncher.app itself.' This implies that NetBeansLauncher
is a directory with the name 'NetBeansLauncher.app'. In the mounted disk image, either right click or Ctrl-click on the NetBeansLauncher icon and choose to 'Show Package Contents'.The structure is the same for all Mac OS X applications. There is a
Contents
directory with an XML file named info.plist
, a text file named PkgInfo, a MacOS directory, and a Resources directory. If you don't have a creator code registered with Apple the PkgInfo text file should contain only the following.If you have a creator code, use it in place of the question marks. Ordinarily the MacOS folder contains a small stub file that launches the Java VM. In this case the NetBeans team has written their own application. We will look more closely at a property list file in the next section. For now, take a look at the contents of the
Resources
directory.You can see the contents of the same
netbeans
package inside of the Resources
subdirectory. This is your key to deploying on Mac OS X. Add in the necessary pieces and then just bundle up your ordinary distribution in the appropriate location. If you have a more flexible build process you should also strip out those pieces that aren't needed for the Mac OS X application such as the Windows executables.If you are interested in digging deeper into the structure of a Mac OS X application, you will find more information in the Apple publication Anatomy of a Bundle.
Creating 'Native' Java Applications on Mac OS X
If you develop on Mac OS X you can use the
Jar Bundler
application to turn jar files into Mac OS X applications. Jar Bundler
is distributed with the other developer tools and is located in Developer/Applications/
. Start it, select the 'Classpath and Files' tab and add the file JavaSoundDemo.jar
.Select the 'Build Information' tab. For 'Main Class', navigate to the
JavaSoundDemo.jar
file again and select JavaSound
from the drop down list. This list is populated by any classes in the jar file containing a main()
method. Accept all of the default settings for the options. You can use the default Java application icon or you can create your own. The icon you see below started as a screen shot of the running Java Sound Demo and was transformed into an icon using the IconComposer
application that is also distributed as part of the developer tools.Press 'Create Application' and enter the name 'JavaSoundDemo'. A Mac OS X application is created for you. You can show the package contents of the generated application as before. You can view the property list with Apple's Property List Editor or with any text editor. It is just an XML file with properties stored as name - value pairs.
The Java properties indicate the location of the jar file, the name of the Main class, and the version of the JRE to be used. The other properties include a pointer to the icon file and to the Java application stub file that is the native executable.
Creating Mac OS X Java Applications on Other Platforms
Take a look at the contents of the package that was generated by
Jar Bundler
on Mac OS X.On another platform you need to duplicate this structure. To create an application named 'JavaSoundDemo' on, say, a Windows machine, start by creating a directory and naming it
JavaSoundDemo.app
. Next, create a subdirectory named Contents
. Inside of Contents
you will need a MacOS
directory with the JavaAPplicationStub
. You can create the PkgInfo
text file and your Info.plist
can also be generated by hand and should contain the following XML.You will need a
Resources
directory with a Java
subdirectory into which you put the JavaSoundDemo.jar
file. In other words, with the exception of the JavaApplicationStub
and the music.icns
file, everything else can be created on another platform.If you use Ant you can easily add a target that takes your jar files, images, and other resources and bundles it up as a Mac OS X application bundle that includes the plist file and Java application stub in the appropriate locations. Every time you create a new build you will automatically have your Mac OS X version. You can also find a growing number of Ant tasks that automate some of the steps outlined in this article.
Summary
When it comes time to deploy your Java application, consider the ease of use of your target audience. Even developers appreciate the double clickable version of the NetBeans IDE. Creating a Java application that looks and feels like a native application does not require a lot of extra work and can easily be integrated into your build process even if your build machine runs a different operating system.
For More Information
It's time to write your first application! These detailed instructions are for users of the NetBeans IDE. The NetBeans IDE runs on the Java platform, which means that you can use it with any operating system for which there is a JDK available. These operating systems include Microsoft Windows, Solaris OS, Linux, and Mac OS X.
- Creating Your First Application
A Checklist
To write your first program, you'll need:
- The Java SE Development Kit (JDK 7 has been selected in this example)
- For Microsoft Windows, Solaris OS, and Linux: Java SE Downloads Index page
- For Mac OS X: developer.apple.com
- The NetBeans IDE
- For all platforms: NetBeans IDE Downloads Index page
Creating Your First Application
Your first application,
HelloWorldApp
, will simply display the greeting 'Hello World!' To create this program, you will:- Create an IDE projectWhen you create an IDE project, you create an environment in which to build and run your applications. Using IDE projects eliminates configuration issues normally associated with developing on the command line. You can build or run your application by choosing a single menu item within the IDE.
- Add code to the generated source fileA source file contains code, written in the Java programming language, that you and other programmers can understand. As part of creating an IDE project, a skeleton source file will be automatically generated. You will then modify the source file to add the 'Hello World!' message.
- Compile the source file into a .class file Projector for mac.The IDE invokes the Java programming language compiler
(javac)
, which takes your source file and translates its text into instructions that the Java virtual machine can understand. The instructions contained within this file are known as bytecodes. - Run the programThe IDE invokes the Java application launcher tool (
java
), which uses the Java virtual machine to run your application.
Create an IDE Project
To create an IDE project:
- Launch the NetBeans IDE.
- https://daytree437.weebly.com/blog/malewarebytes-for-mac. On Microsoft Windows systems, you can use the NetBeans IDE item in the Start menu.
- On Solaris OS and Linux systems, you execute the IDE launcher script by navigating to the IDE's
bin
directory and typing./netbeans.
- On Mac OS X systems, click the NetBeans IDE application icon.
- In the NetBeans IDE, choose File | New Project...NetBeans IDE with the File | New Project menu item selected.
- In the New Project wizard, expand the Java category and select Java Application as shown in the following figure:NetBeans IDE, New Project wizard, Choose Project page.
- In the Name and Location page of the wizard, do the following (as shown in the figure below):
- In the Project Name field, type
Hello World App
. - In the Create Main Class field, type
helloworldapp.HelloWorldApp
.
NetBeans IDE, New Project wizard, Name and Location page. - Click Finish.
The project is created and opened in the IDE. You should see the following components:
- The Projects window, which contains a tree view of the components of the project, including source files, libraries that your code depends on, and so on.
- The Source Editor window with a file called
HelloWorldApp.java
open. - The Navigator window, which you can use to quickly navigate between elements within the selected class.NetBeans IDE with the HelloWorldApp project open.
Add JDK 8 to the Platform List (if necessary)
It may be necessary to add JDK 8 to the IDE's list of available platforms. To do this, choose Tools | Java Platforms as shown in the following figure:
Selecting the Java Platform Manager from the Tools Menu
If you don't see JDK 8 (which might appear as 1.8 or 1.8.0) in the list of installed platforms, click Add Platform, navigate to your JDK 8 install directory, and click Finish. You should now see this newly added platform:
The Java Platform Manager
To set this JDK as the default for all projects, you can run the IDE with the
--jdkhome
switch on the command line, or by entering the path to the JDK in the netbeans_j2sdkhome
property of your INSTALLATION_DIRECTORY/etc/netbeans.conf
file.To specify this JDK for the current project only, select Hello World App in the Projects pane, choose File | Project Properties (Hello World App), click Libraries, then select JDK 1.8 in the Java Platform pulldown menu. You should see a screen similar to the following:
The IDE is now configured for JDK 8.
Add Code to the Generated Source File
When you created this project, you left the Create Main Class checkbox selected in the New Project wizard. The IDE has therefore created a skeleton class for you. You can add the 'Hello World!' message to the skeleton code by replacing the line:
with the line:
Optionally, you can replace these four lines of generated code:
with these lines:
These four lines are a code comment and do not affect how the program runs. Later sections of this tutorial explain the use and format of code comments.
Be Careful When You Type
Note: Type all code, commands, and file names exactly as shown. Both the compiler (
javac
) and launcher (java
) are case-sensitive, so you must capitalize consistently.HelloWorldApp
is not the same as helloworldapp
.Save your changes by choosing File | Save.
The file should look something like the following:
Compile the Source File into a .class File
To compile your source file, choose Run | Build Project (Hello World App) from the IDE's main menu.
The Output window opens and displays output similar to what you see in the following figure:
Output window showing results of building the HelloWorld project.
If the build output concludes with the statement
BUILD SUCCESSFUL
, congratulations! You have successfully compiled your program!Netbeans For Mac Mojave
If the build output concludes with the statement
BUILD FAILED
, you probably have a syntax error in your code. Errors are reported in the Output window as hyperlinked text. You double-click such a hyperlink to navigate to the source of an error. You can then fix the error and once again choose Run | Build Project.When you build the project, the bytecode file
HelloWorldApp.class
is generated. You can see where the new file is generated by opening the Files window and expanding the Hello World App/build/classes/helloworldapp node as shown in the following figure.Files window, showing the generated .class file.
Now that you have built the project, you can run your program.
Run the Program
Netbeans For Mac Osx
From the IDE's menu bar, choose Run | Run Main Project.
The next figure shows what you should now see.
The program prints 'Hello World!' to the Output window (along with other output from the build script).
Netbeans For Macbook Air
Congratulations! Your program works!
Continuing the Tutorial with the NetBeans IDE
The next few pages of the tutorial will explain the code in this simple application. After that, the lessons go deeper into core language features and provide many more examples. Although the rest of the tutorial does not give specific instructions about using the NetBeans IDE, you can easily use the IDE to write and run the sample code. The following are some tips on using the IDE and explanations of some IDE behavior that you are likely to see:
Netbeans For Mac High Sierra
- Once you have created a project in the IDE, you can add files to the project using the New File wizard. Choose File | New File, and then select a template in the wizard, such as the Empty Java File template.
- You can compile and run an individual file (as opposed to a whole project) using the IDE's Compile File (F9) and Run File (Shift-F6) commands. If you use the Run Main Project command, the IDE will run the file that the IDE associates as the main class of the main project. Therefore, if you create an additional class in your HelloWorldApp project and then try to run that file with the Run Main Project command, the IDE will run the
HelloWorldApp
file instead. - You might want to create separate IDE projects for sample applications that include more than one source file.
- As you are typing in the IDE, a code completion box might periodically appear. You can either ignore the code completion box and keep typing, or you can select one of the suggested expressions. If you would prefer not to have the code completion box automatically appear, you can turn off the feature. Choose Tools | Options | Editor, click the Code Completion tab and clear the Auto Popup Completion Window checkbox.
- If you want to rename the node for a source file in the Projects window, choose Refactor from IDE's main menu. https://daytree437.weebly.com/blog/2tb-external-hard-drives-for-mac. The IDE prompts you with the Rename dialog box to lead you through the options of renaming the class and the updating of code that refers to that class. Make the changes and click Refactor to apply the changes. This sequence of clicks might seem unnecessary if you have just a single class in your project, but it is very useful when your changes affect other parts of your code in larger projects.
- For a more thorough guide to the features of the NetBeans IDE, see the NetBeans Documentation page.