[Tutorial] NetBeans IDE

Discussion in 'Spigot Discussion' started by Elite, Mar 29, 2016.

  1. I wrote a few tutorials to try and help anyone who wants to give NetBeans a go :)


    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    The first tutorial is on how and where to Download NetBeans IDE and how to Install it

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Step 1)

    First, you need to make sure you have a JDK (Java Development Kit)

    If you already have one skip to Step 2

    If you don't have one, you may download one here: http://www.oracle.com/technetwork/java/javase/downloads

    You'll want to choose JDK 7 (update 10 or later) or JDK 8

    (optional) There is a download option to install NetBeans with JDK 8 - This will skip Step 2




    Step 2)

    Go to: https://netbeans.org/downloads/

    You should see a table with the different types of IDE Download Bundles

    **Make sure the IDE Language and the Platform matches your Operating System and Desired Language
    **It may default to Windows, change this if you are on a Mac, Linux, or Independent OS

    You may find those options in drop-down menus above the table.

    Java SE may work fine, but if you want more feature/language support, select Java EE or the All options.




    Step 3)

    Locate where the installer downloaded to. (Most common locations are Download folder and Desktop)

    [​IMG]

    This is what the icon should look like (The naming may vary depending on your platform)


    - Run the application -



    *If you have UAC (User Account Control) on - You may have a popup alerting if you want to proceed

    [​IMG]

    Click [Yes]



    The installer should now begin configurations.

    [​IMG]



    Step 4)

    [​IMG]

    If you want to specify what you want to install click [Customize]

    If you want to install everything - click [Next] and skip to Step 6




    Optional | Step 5)

    Choose what you want to install (For this tutorial the first 3 is recommended, the rest is optional)

    (I personally left them all checked)

    [​IMG]



    Step 6)

    Accept the license agreement terms

    Click [Next]

    [​IMG]



    Step 7)

    Choose the NetBeans IDE folder location

    ---

    Choose the JDK being used for NetBeans IDE

    *jdk1.7 update 10 and later is required (For more information go to Step 1)

    ---

    Click [Next]

    [​IMG]



    Skip if not selected | Step 8)

    Choose the glassfish folder location

    ---

    Choose the JDK being used for NetBeans IDE

    *jdk1.7 update 10 and later is required (For more information go to Step 1)

    ---

    Click [Next]

    [​IMG]



    Step 9)

    *Optional - Check the 'Check for Updates' selection

    Click [Install]

    [​IMG]

    The installation should now be in progress.

    [​IMG]



    Final Step)

    You should now be at a setup complete window

    [​IMG]

    Click [Finish] to close the window

    *Optionally - You may now see an Icon on your Desktop

    [​IMG]




    This concludes the NetBeans Download and Installation tutorial :)
     
    #1 Elite, Mar 29, 2016
    Last edited: Mar 29, 2016
    • Like Like x 2
    • Useful Useful x 1
  2. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    This second tutorial is how to setup and run a Bukkit or Spigot plugin in the NetBeans IDE environment

    I don't show you how to code a massive plugin in this tutorial, only on how to get one created and working.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Step 1)

    When you first load up NetBeans IDE - If there is no 'New Project' window open go to Step 2

    If it's already open go to Step 3

    [​IMG]



    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Creating a Project | Step 2 - 4

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




    Step 2)

    To create a New Project | Click File -> New Project...

    [​IMG]



    Step 3)

    With the New Project window open - You'll want to click Maven - Then choose Java Application

    Then click [Next]

    [​IMG]



    Step 4)

    Fill in the boxes information about your Project:

    Project Name - What would you like the folder to be called?
    (The plugin (jar file) defaults to this name, but 'can' be different)

    Project Location - Specify where you want the folder to be made that holds the plugin and source code
    (I usually leave it on the default location - Unless you want it somewhere specific (ie. Desktop))

    Artifact ID: Defaults to the project name

    Group ID: This usually specifies part of the package location.

    Version: What do you want the version to start at?
    (Defaults to 1.0)

    Package: A more in-depth specification of the package (Folder that holds the classes - used for imports)

    [​IMG]



    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Adding Dependencies | Step 5 - 6

    **This is for adding a dependency using the 'Add Dependency' Window

    **If you prefer adding a Dependency manually using a pom.xml go to Step 13

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




    Step 5)

    To add a Dependency | Right Click Dependencies -> Add Dependency...

    [​IMG]



    Step 6)

    Inside the Query text box, you will type: Spigot or Bukkit (or another dependency)

    Results should appear below it

    ...Then click the version you want to build off of.

    [​IMG]

    Click [Add]

    It should show up in the Dependencies folder once it downloaded

    [​IMG]



    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Adding Classes | Step 7 - 9

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




    Step 7)

    To add a Java Class file:

    Expand Source Packages (Click the plus symbol or the package itself)

    Right-Click the default package (if it exists)

    Hover over New and click Java Class

    [​IMG]



    Step 8)

    Class Name: The name of the class/java file

    The Main class is generally called Main - Though it is not 'required' ...it just has to be specified later as such.

    Click [Finish]

    [​IMG]



    Step 9)

    The Main.java file should look similar to below:

    Generally yours may show Authors/Licence comments by Default - I have it removed from my Templates

    Your color scheme may also be different - I have a darker theme specified.

    [​IMG]

    Let's add in some minimal code to test the plugin later

    Code (Text):

    package elite.tutorial;

    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin {
     
        @Override
        public void onEnable(){
            System.out.println("Enabling this plugin works.");
        }
     
        @Override
        public void onDisable(){
            System.out.println("Disabling this plugin works.");
        }
    }
     
    You will extend JavaPlugin - This is required for Bukkit/Spigot plugins

    Doing so will also require you to add its import location

    -In the example we also add a System.out.println() message to specify when the plugin successfully loads and unloads when the server is enabled and disabled.



    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    YAML Files | Step 10 - 12

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




    Step 10)

    How will we specify what the Main class is? We need a YAML file for this

    To add a YAML File:

    Right-Click Source Packages

    Hover over New and click YAML File



    Step 11)

    File Name:
    The name of the YAML file

    For this section you need to type: plugin

    Folder: Which folder in the project the YAML file goes in

    Defaults to src\main\java

    Click [Finish]

    [​IMG]



    Step 12)

    You should now have a file in a <default package> inside the Source Package

    name (required): The name of your plugin

    main (required): Specify the location of your Main.java file (Package name + Class name)

    version (required): Write the version you want this plugin to be

    description (optional): Write what your plugin does in a short description

    For more information on YAML - Visit this link: http://wiki.bukkit.org/Plugin_YAML

    [​IMG]



    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Editing the pom.xml | Step 13 - 15

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




    Step 13)

    Expand Project Files (Using the plus symbol or clicking Project Files)

    Click and Open pom.xml

    [​IMG]



    Step 14)



    [​IMG]


    You should have most things specified, but to have it work - you most likely need to alter some text

    Example pom.xml 'after' editing

    Code (Text):

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>elite</groupId>
        <artifactId>Tutorial</artifactId>
        <version>1.0.1</version>
        <name>Tutorial</name>
        <repositories>
            <repository>
                <id>spigot-repo</id>
                <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
            </repository>
        </repositories>
        <build>
            <sourceDirectory>src</sourceDirectory>
            <resources>
                <resource>
                    <filtering>true</filtering>
                    <directory>src</directory>
                    <includes>
                        <include>plugin.yml</include>
                    </includes>
                </resource>
            </resources>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.5.1</version>
                    <configuration>
                        <finalName>Tutorial</finalName>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
        <dependencies>
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot</artifactId>
                <version>1.8-R0.1-SNAPSHOT</version>
            </dependency>
        </dependencies>
    </project>
     
    For a more in-depth pom.xml tutorial - Please go here: https://www.spigotmc.org/wiki/spigot-maven/#pom-xml



    Optional - Spelling Issue | Step 15)


    If you save a pom.xml file - Sometimes it may change the naming of your packages or class files

    [​IMG]

    From our previous example pictures you may notice it changed:

    <default package> --> main.java

    elite.tutorial
    --> main.java.elite.tutorial

    ---

    To fix this - expand main.java package and drag plugin.yml to Source Package

    Then Right-Click main.java.elite.tutorial - Hover over Refactor - and click Rename

    (Your package names may not be the same as mine - This is just an example)

    [​IMG]



    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Compiling the Plugin | Step 16

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




    Step 16)

    To compile in NetBeans is very easy

    Click [Run] in your menu | Then click Clean and Build Project (Project Name)

    [​IMG]

    You should now see a Build Output at the bottom of your window

    If it compiled correctly it will say BUILD SUCCESS

    [​IMG]



    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Running the Plugin | Step 17 - 19

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




    Step 17)

    Open the target location - It should be where you specified in Step 4

    [​IMG]



    Step 18)

    Copy/Paste the jar into your Server's plugins folder

    [​IMG]
     
    #2 Elite, Mar 29, 2016
    Last edited: Feb 3, 2018
    • Like Like x 2
    • Useful Useful x 1

  3. Step 19)


    Run your server (Optionally restart your server - if it's live)

    [​IMG]



    Results)

    [​IMG]

    Notice the blue underlined text - It's the text we specified in the code in Step 9

    This means the onEnable() works

    Now if we type stop in the console (or in-game if it's allowed)

    [​IMG]

    This underline text shows that the onDisable() works as well

    From here just edit the code as you will -> recompile it -> copy/paste the jar -> and restart the server




    This is how to set up a plugin using the NetBeans IDE and concludes the Plugin-Setup Tutorial :)
     
    • Like Like x 1
    • Useful Useful x 1
  4. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    The last tutorial is in progress - I will write shortcuts, tips, and tricks that can help you within NetBeans

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


    In progress
     
    • Like Like x 1
    • Useful Useful x 1
  5. thanks for the help
     
    • Like Like x 1
  6. Hello, thanks for amazing work :)

    I have tried that auto-dependency stuff, but it cannot find Spigot.. Why is that?
     

    Attached Files:

    • Like Like x 1
  7. not trying to shitpost, but eclipse is better and you should've done an eclipse one ;3
    personal preference lmfao
     
    • Optimistic Optimistic x 1
    • Creative Creative x 1
  8. I really hate Eclipse in all ways. It's too slow and buggy. NetBeans is Oracle official.
     
    • Like Like x 1
  9. Thanks for the tutorial using NetBeans, Elite! My nephew and I are trying to learn java for plugins using a book which uses NetBeans. It's really helpful to see the screenshots!
     
    • Like Like x 1
  10. My old Minecraft IGN was NetBeans, I'm thinking of changing it back.

    Anyway, back to topic, this guide is really useful and I wish you had posted this earlier when I used to use NetBeans. I'm sure it will help many people.
     
    • Like Like x 1
  11. thanks
     
    • Like Like x 1
  12. Nah dude IntelliJ. I used eclipse in college for 3 years. Moved to IntelliJ never looked back, seriously!
     
    • Agree Agree x 2
  13. You can't say those two things in one quote dude..

    "eclipse is better' and then "personal preference"

    If it's only better for you personally, then it's a moot argument to claim it's better.

    That's like saying: Dude, don't buy a car, because I don't have a license, so I can't ride one anyway.
     
    • Like Like x 1
    • Funny Funny x 1

  14. That must look up a directory online or something, for spigot (the spigot dependency now not the spigot-api) since they cannot host this as a maven repo due to DCMA you will have to use buildtools to build the latest version which will install the latest spigot in your local .m2 repositories. Then add this to your pom.xml ->

    Code (Text):

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.12.2-R0.1-SNAPSHOT</version>
        </dependency>
    </dependencies>
     
    I always since I need to build the latest spigot I only use local repos, I know you could reference the online ones if needed.

    See this post for online versions availible: https://www.spigotmc.org/wiki/spigot-maven/
     
    • Informative Informative x 1
  15. Do you guys also wants a tutorial on how to shitpost in a 2 years old post?
     
    • Funny Funny x 2
    • Agree Agree x 1
  16. I reply to what's new page, i am not always in the situation where I go back to the date on each post, vs last 3 posts, etc. I respond to what's listed in what's new and if the last few posts dont say 'this is x years old, dont bump it', i can only assume it's an ongoing conversation. Sorry if i got sucked into a dead thread that didn't get closed
     
    • Agree Agree x 2
  17. I was not trying to accuse anyone, might have been a bit too aggressive :eek:
     
  18. Eh, i could have taken it lighter as well. It's not the weekend.
     
  19. a post from 2016.
    irrelevant but i use intellij now
     
  20. Me too :p
    hehe
     

Share This Page