Building NetBeans on NixOS fails

Hey,

I currently try to build NetBeans with NixOS which fails. I’ve double checked with a Ubuntu VirtualBox image which works.

Source Repo: GitHub - apache/netbeans: Apache NetBeans
Branch: release123

shell.nix

{ pkgs ? import <nixpkgs> {
  overlays = [ (self: super: {
    jdk = super.jdk8;
  }) ];
} }:
pkgs.mkShell {
  buildInputs = with pkgs; [
    ant
    jdk
  ];
}

Build:

ant -Dcluster.config=basic
...
   [repeat] import com.sun.jdi.ClassType;
   [repeat]                   ^
   [repeat] /home/asbachb/dev/extsrc/netbeans/java/api.debugger.jpda/src/org/netbeans/spi/debugger/jpda/Evaluator.java:23: error: package com.sun.jdi does not exist
   [repeat] import com.sun.jdi.ObjectReference;
   [repeat]                   ^
   [repeat] /home/asbachb/dev/extsrc/netbeans/java/api.debugger.jpda/src/org/netbeans/spi/debugger/jpda/Evaluator.java:24: error: package com.sun.jdi does not exist
   [repeat] import com.sun.jdi.StackFrame;
   [repeat]                   ^
   [repeat] /home/asbachb/dev/extsrc/netbeans/java/api.debugger.jpda/src/org/netbeans/spi/debugger/jpda/Evaluator.java:25: error: package com.sun.jdi does not exist
   [repeat] import com.sun.jdi.Value;
   [repeat]                   ^
   [repeat] /home/asbachb/dev/extsrc/netbeans/java/api.debugger.jpda/src/org/netbeans/spi/debugger/jpda/Evaluator.java:137: error: cannot find symbol
   [repeat]         private StackFrame stackFrame;
   [repeat]                 ^
   [repeat]   symbol:   class StackFrame
   [repeat]   location: class Context
   [repeat] /home/asbachb/dev/extsrc/netbeans/java/api.debugger.jpda/src/org/netbeans/spi/debugger/jpda/Evaluator.java:139: error: cannot find symbol
   [repeat]         private ObjectReference contextObject;
   [repeat]                 ^
   [repeat]   symbol:   class ObjectReference
   [repeat]   location: class Context
   [repeat] /home/asbachb/dev/extsrc/netbeans/java/api.debugger.jpda/src/org/netbeans/spi/debugger/jpda/Evaluator.java:177: error: cannot find symbol
   [repeat]         public StackFrame getStackFrame() {
   [repeat]                ^
   [repeat]   symbol:   class StackFrame
   [repeat]   location: class Context
   [repeat] 100 errors
  [nbmerge] Failed to build target: all-api.debugger.jpda

BUILD FAILED
/home/asbachb/dev/extsrc/netbeans/nbbuild/build.xml:643: The following error occurred while executing this line:
/home/asbachb/dev/extsrc/netbeans/nbbuild/build.xml:638: The following error occurred while executing this line:
/home/asbachb/dev/extsrc/netbeans/nbbuild/build.xml:685: The following error occurred while executing this line:
/home/asbachb/dev/extsrc/netbeans/nbbuild/templates/common.xml:206: Compile failed; see the compiler error output for details.

So it seems that the build is unable to find classes which are located in tools.jar

grep -Hls IllegalConnectorArgumentsException /nix/store/ghl7zxsp26nz4k85p24xgd7lvc9p2ifh-openjdk-8u272-b10/lib/openjdk/lib/tools.jar
/nix/store/ghl7zxsp26nz4k85p24xgd7lvc9p2ifh-openjdk-8u272-b10/lib/openjdk/lib/tools.jar

Which is strangely part of the classpath.

I’m a little bit puzzled how to debug that problem any further.

That’s indeed surprising. You didn’t share why you wanted to compile netbeans, so I’ll just share some things I saw which may or may not be useful to you :wink: .

What nixpkgs are you on? I’m on nixos-unstable, which has netbeans 12.3, so the quick way to get netbeans is nix-shell -p netbeans. The HEAD of the release123 branch corresponds with the 12.3-beta3 and 12.3-vc1 tags. It’s not quite clear to me, but it seems like that’s what the 12.3 release binary was also built from?

If you just want to use netbeans, but you’re not on nixos-unstable, you could get just this one package from nixos-unstable, or use the derivation from unstable as a starting point for your own.

If you want to hack on netbeans, unfortunately the derivation in nixpkgs doesn’t help you, since it takes the binary release instead of building from source. When I try to build from source using the shell.nix you started, I get a different error, though:

     [java] > Task :clean UP-TO-DATE
     [java] > Task :compileJava NO-SOURCE
     [java] > Task :compileGroovy FAILED
     [java] 2 actionable tasks: 1 executed, 1 up-to-date
     [java] 
     [java] FAILURE: Build failed with an exception.
     [java] 
     [java] * What went wrong:
     [java] Execution failed for task ':compileGroovy'.
     [java] > Could not find tools.jar. Please check that /nix/store/rfhb6lmwwbnw47j7zilp7pxfppjjhm4f-openjdk-8u272-b10-jre/lib/openjdk/jre contains a valid JDK installation.

Not sure where it’s getting /nix/store/rfhb6lmwwbnw47j7zilp7pxfppjjhm4f-openjdk-8u272-b10-jre/lib/openjdk/jre from though - JAVA_HOME points to /nix/store/ghl7zxsp26nz4k85p24xgd7lvc9p2ifh-openjdk-8u272-b10/lib/openjdk which does contain a lib/tools.jar

Actually I want to fix/improve a NetBeans feature. That’s the reason I need to compile the platform.

I’m on nixos-unstable.

The log you posted is a little bit weird since ant is using the jre instead of the jdk.

Makes sense

Exactly! ant itself is running with /nix/store/ghl7zxsp26nz4k85p24xgd7lvc9p2ifh-openjdk-8u272-b10/lib/openjdk/bin/java though (checked with ‘ps’), and that jre is not in my env… so I’m not sure where gradle is getting it. Removing my ~/.gradle and running in nix-shell --pure didn’t help either.

(sorry for not being helpful at all, but just adding more problems to the thread… feel free to ignore :wink: )