[broken] How to easy test your plugin with netbeans

Discussion in 'Resources' started by ferrybig, Jan 21, 2013.

?

after you read this, do you use this?

  1. Yes, I configured my ide to use this

    40.4%
  2. No, I keep moving the files over to my test server

    7.0%
  3. No, I use eclipse

    52.6%
Thread Status:
Not open for further replies.
  1. Most plugin developers want to test their plugin from the ide, with Netbeans, you can do this.

    To set up this feature, you need to have craftbukkit (instead of bukkit) at the classpath of your project you want to set up using this, then configure it like this:
    [​IMG]
    Explanation of the options inside the screenshot:
    Main class: the class netbeans calls to start your project, in this case, we want it to start bukkit
    Program arguments: here we specify that the plugin folder is found at ../dist and that we don't use JLine (JLine bugs with Netbeans output field)
    Working directory: here we specify the path where the important files of the server are found, like bukkit.yml and server.properties
    VM Options: here we specify the VM options that we use to start the server, like the amount of RAM

    Example testing my own plugin: multiworld
    [​IMG]

    Side notes:
    * as far I know, eclipse dont have this option to test from the ide
    * using this methodes runs the server with the exact the same version as your compiled your plugin, you don't have to update your server to test as its automatically the same version
    * use the clean and build option to remove the directory of the plugin, so you can start over with its data
     
  2. Offline

    rmh4209

    Just to let you know, I just did this in Eclipse. It works beautifully. Thank you.
     
  3. Offline

    Diemex

    I use Eclipse and what I do is just export the plugin as a jar and then I reload my testserver which is just constantly running in the background. Is there a better way to do this?
     
  4. Offline

    Zarius

    Diemex - this is what I do too (reload constantly running testserver), that way I don't need to stop/start the server all the time. Although after too long of testing I do run out of permgen space :D
     
  5. Offline

    KeybordPiano459

  6. Offline

    RainoBoy97

    I think i prefer the old fashion way :p Then i can test commands etc too :)
     
  7. Offline

    caldabeast

    Did this in Eclipse as well
    This.
    This is glorious.

    My question is, though:
    How can I get it to load my plugin without having to export a new jar of it?
    This way, I could use the debug mode in Eclipse.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  8. try setting the main class to that from craftbukkit

    with this, you can test commands from console too type them inside the output field, or do op <your name> to add yourself to the op list so you can test them from ingame

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  9. Offline

    RainoBoy97

    So this is a local server that i can join? Nice
     
  10. Offline

    KeybordPiano459

    ferrybig
    I've tried making a plugins folder in the server directory, and then using my nbproject/project.properties file to set the jar export location to that folder, but even when my jar is in there, the server doesn't load my plugin =/ How does your situation work?
     
  11. inside my situation, the folders are set up like this
    multiworld # main project folder
    * dist #default output directy of resulting build
    * server #Folder I created to contain the server
    * build # a directory from netbeans
    * src # Another directory from netbeans
    * nbproject # Another directory from netbeans

    I configured the server with the following parameters: "-P ../dist"
    that says to the server, look up plugins inside multiworld/server/../dist instead of multiworld/server/plugins
    multiworld/server/../dist is going to converted to multiworld/dist so it picks up the last build from the dist folder
     
  12. Offline

    KeybordPiano459

    I should've noticed that :p
    Thanks :)
     
  13. Works perfectly whit eclipse
     
  14. Offline

    iWareWolf

    My plugins aren't loading into the server
     
  15. you need to configure the directory where bukkit searches the .jar file, in my example I used this command line thing: -P ../dist as its the default build directory of netbeans
     
  16. Offline

    FalseVacuum

    Did you get this to work? That would be super epic.
     
  17. Offline

    caldabeast

    No, I didn't. I got it to run when I pressed the Play button in Eclipse, but I couldn't get it to dynamically load my plugin.
     
  18. does eclipse build a jar when you press the play button?
     
  19. Offline

    caldabeast

    not sure
     
  20. I asked it, because this work at the following way:
    when you play your project, your ide sets the class path to your build directory and to craftbukkit
    when craftbukkit sees your plugin inside the directory, it tries to load the class, java catches its and redirect it to the class path, because that's calculated first, and because of that, it uses the new files
     
  21. It's nice to see someone using NetBeans like me. I never see tutorials for NetBeans.
     
    hamzaxx likes this.
  22. Offline

    the_merciless

    This is awesome, I got it working on eclipse too, its quite laggy though, any ideas on how to improve that?

    ferrybig caldabeast
    I done this and it kept making a new file called dist, solved it by clicking "variables" in the Project arguments section and selecting project_loc

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  23. ferrybig

    Doing this on Ubuntu 12.04 with NetBeans 8 on Java 7 Oracle produces the following log when i run:

    Code:
    run:
    Loading libraries, please wait...
    java.lang.SecurityException: sealing violation: can't seal package org.bukkit.event.block: already loaded
        at java.net.URLClassLoader.getAndVerifyPackage(URLClassLoader.java:395)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:417)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at net.minecraft.server.v1_7_R3.StatisticList.c(SourceFile:95)
        at net.minecraft.server.v1_7_R3.StatisticList.a(SourceFile:59)
        at net.minecraft.server.v1_7_R3.DispenserRegistry.b(SourceFile:359)
        at net.minecraft.server.v1_7_R3.MinecraftServer.main(MinecraftServer.java:688)
        at org.bukkit.craftbukkit.Main.main(Main.java:159)
    BUILD SUCCESSFUL (total time: 9 seconds)
    
    Any idea?
     
  24. It seems bukkit has forced the javaplugin to be loaded by the javapluginclassloader, this trick no longer works
     
  25. =(
     
  26. Offline

    ChipDev

    Netbeans... srsly that name haunts me
    internet BEANZ
     
  27. Offline

    RawCode

    * as far I know, eclipse dont have this option to test from the ide

    lol wut?
    [​IMG]

    eclipse do allow to test from IDE and do allow "macrostart"(jar your plugins place to proper folder and then run server, cleunp logs and etc without 3rd party addons, but some coding may be required if you going to do something crazy"
     
  28. Offline

    HellsMiner

    Sadly, this doesn't work for me. I always get this error:

    Code:
    [15:47:51 ERROR]: Could not load '..\dist\MyPlugin.jar' in folder '..\dist'
    org.bukkit.plugin.InvalidPluginException: java.lang.IllegalStateException: JavaPlugin requires org.bukkit.plugin.java.PluginClassLoader
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:328) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugins(CraftServer.java:355) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.<init>(CraftServer.java:317) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.PlayerList.<init>(PlayerList.java:68) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.DedicatedServer.init(DedicatedServer.java:126) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:436) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
    Caused by: java.lang.IllegalStateException: JavaPlugin requires org.bukkit.plugin.java.PluginClassLoader
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:64) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at de.hellsminer.somepackage.MainPluginClass<init>(MainPluginClass.java:35) ~[classes/:?]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_60]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[?:1.7.0_60]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.7.0_60]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[?:1.7.0_60]
        at java.lang.Class.newInstance(Class.java:374) ~[?:1.7.0_60]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:52) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:127) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        ... 9 more
    outside netbeans everything is working...
    Anyone who knows why?
     
Thread Status:
Not open for further replies.

Share This Page