NetBeans 12 doesn't manage libraries anymore - java

A week ago I upgraded my Java IDE to Netbeans 12 (and JDK 14), and only yesterday I noticed the window Project Properties (MYPROG) lacks of essential functionality i.e. there are not lines for compiling in *.jar, and mostly there is not any line for adding *.jar libraries, there is instead an empty line for JavaScript libraries, and it is impossible to add them in any other point.
The real oddity of NetBeans 12 is that it works perfectly even with old projects made with NetBeans 8 and JDK6! but reinstalling previous NetBeans 10 still remaisn a trouble.
I'm stuck making new projects that need libraries.
Minor problems are: System.err.println doesn't write in red colour, the path src/mycode has become src/main/java/mycode, why? and perhaps many others.
My attempts are over.
I've installed
OS: Window 10
jdk-14_window-x64_bin.exe
Apache NetBeans 12 LTS
Binaries: netbeans-12.0-bin.zip (SHA-512, PGP ASC) 1st try
Installers: Apache-NetBeans-12.0-bin-windows-x64.exe (SHA-512, PGP ASC) 2nd try.
It's a Java project using Maven
I don't know Gradle and Ant (what are they for?)
Project Properties (MYPROG)-->Build has only Compile without Compiling, Packaging, Deployment, Documenting
Project Properties (MYPROG)--> Libraries does not exist
instead: JavaScript libraries (empty)

When you are using Maven, the Project properties do not have a Libraries section, because the libraries are managed through Maven (and not NetBeans).
You manage the needed libraries through the "Dependencies" node of the project or by editing pom.xml directly:
But this has been the case since NetBeans started supporting Maven (so probably 8.0 or something along those lines). If you had a "Libraries" section in the project properties before, you were using an Ant based project.
path src/mycode has become src/main/java/mycode, why?
Because src/main/java is the default directory layout Maven uses.

If you recreate the project as Ant project, you will have the option to import library in the project properties.
Netbeans Java project with Ant

Related

Eclipse Oxygen - The project was not built since its build path is incomplete

I just installed Eclipse Oxygen and tried to open an existing project into the workbench but I get this error:
The project was not built since its build path is incomplete. Cannot
find the class file for java.lang.Object. Fix the build path then try
building this project
I tried right clicking on the project - went to Properties - Java Build Path - Libraries - Add Library - JRE System Library and selected Workbench default JRE (jre1.8.0_60).
I then cleaned and rebuilt the project but it then causes more errors to come up like:
ActionBar cannot be resolved to a type
Activity cannot be resolved to a variable
AdapterView cannot be resolved to a type
ArrayAdapter cannot be resolved to a type
Here is what made the error disappear for me:
Close eclipse, open up a terminal window and run:
$ mvn clean eclipse:clean eclipse:eclipse
Are you using Maven? If so,
Right-click on the project, Build Path and go to Configure Build Path
Click the libraries tab. If Maven dependencies are not in the list, you need to add it.
Close the dialog.
To add it:
Right-click on the project, Maven → Disable Maven Nature
Right-click on the project, Configure → Convert to Maven Project.
And then clean
Edit 1:
If that doesn't resolve the issue try right-clicking on your project and select properties. Select Java Build Path → Library tab. Look for a JVM. If it's not there, click to add Library and add the default JVM. If VM is there, click edit and select the default JVM. Hopefully, that works.
Edit 2:
You can also try going into the folder where you have all your projects and delete the .metadata for eclipse (be aware that you'll have to re-import all the projects afterwards! Also all the environment settings you've set would also have to be redone). After it was deleted just import the project again, and hopefully, it works.
In Eclipse, Right click Project -> Maven -> Update Project. It fixed errors in my project.
I'm also using Eclipse Oxygen, migrated from Mars. I faced the same error. I deleted .metadata, .recommenders folders and added projects from archive and issue is solved. I also use Android Studio but i like Eclipse much more.
At my system the Java Runtime JAR file jrt-fs.jar was not found because it was in the wrong directory. This file should be located in the "lib" subfolder. If you installed Java at "C:\Temp\java" the file should be here at C:\Temp\java\lib\jrt-fs.jar .
These are the steps to make jrt-fs.jar available to Eclipse:
Window / Preferences -> the "Preferences" Window opens
Select in the left menu: Java / Installed JREs
Press the [Add...] Button -> A window opens
Select "Standard VM" - The window "JRE Definition" opens.
Enter your path information:
JRE home = "C:\Temp\java"
JRE name = "MyJRE"
Select [Add External JARs...] to link the jrt-fs.jar
JRE system libaries: "C:\Temp\java\lib\jrt-fs.jar"
It worked for me with OpenJDK12 and Eclipse 2019-09 (4.13.0).
Eclipse reported me this error:
The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project
I had faced this problem. I added the C:\Users\Office 2\android-sdks\platforms\android-19\android.jar to the Java Build Path's Library. And the project started to run again.
The problem occurred due to my carelessness. Yesterday night I was updating the Android SDK, and at the same time I tried to run the project, while the SDK Manager was uncompressing the system image. The Project couldn't start and the error occurred.
I tried all the methods given by others. But nothing worked. It solved when I added the android.jar to the library.
I guessed it that android library is missing. not the Java, when I saw the errors only at the android methods and imports. But when I read the posts, I got confused and wasted some time trying wrong way.
I had faced the same issue and tried different solutions, I have reinstalled my JDK 11 and restarted the machine, after that the issue gets resolved.
I got this out of the blue in a workspace that was working properly before. This problem seems to indicate that the project configuration somehow got corrupted.
Restarting Eclipse didn't help, but in the same vein as the answers dealing with Maven, regenerating the Eclipse project config with:
./gradle eclipse
or
./gradlew eclipse
if you use the wrapper, solved this problem for me.
I have similar issue when importing Spring Boot, jdk 11 (using
inside docker) project to Eclipse 2019 (2021), in Ubuntu, instead when
importing to Inteelij IDEA Community or NetBeans IDEs they do
not produce the same set of after-import errors as in Eclipse.
The Spring Boot is multimodule maven projects and two child
modules give such 2 "problems" in appropriate problems tab:
The project was not built since its build path is incomplete.
Cannot find the class file for java.lang.Object. Fix the build
path then try building this project
Next 2 errors are produced in two classes of aforementioned
maven modules:
The type java.lang.Object cannot be resolved. It is
indirectly referenced from required .class files
Manipulation with adding JDK 11 to submodules buildpath
just leads to the thousands of problems. Also it is
got when I use Eclipse-File-Maven-Update.
Moreover when I try to edit most of existing classes or add new ones
I got red underline that tells
Implicit super constructor Object() is undefined for default
constructor. Must define an explicit constructor
. So almost no opportunity to use Eclipse
even at prebuild stage as docker-compose should run build and
run. Indeed I noted that such issue is produced just when project
also uses modules (module-info files introduced in java9).
When I import project on jdk 8 (even not installed on
system), or even on jdk11 without module-info files all
is fine in Eclipse after import.
Another difference is that of when I use problem old no module
project the Build Path is composed with jre environment 8 and
maven dependency items, but when using
"module-info" project the Build path contains -module path,
and -classpath. So I even do not know where to add jre 11,
indeed adding does not resolve issue, just make more errors.
So what is the resolution of the case??? What settings to do
in Eclipse?

Having trouble converting Java Project to Eclipse Plug-in Development Project

I am going through The Eclipse Debug Framework tutorial which was presented at Eclipse con 2005 (https://www.eclipsecon.org/2005/tutorials.html). The Zip file (which can be downloaded from the link) contains 7 exercises. For each exercise an initial code base consisting of two plug-ins is provided - example.debug.core and example.debug.ui.
I tried to import these projects as Plugin and fragments but it doesn't work. (These Projects are not shown as Plugin Projects in the Dialog)
So then I decided to import these projects as Java Projects by "File > Import > Existing Project into Workspace" but then I can't seem to convert them to PDE Projects. I tried it by following these instructions here.
I am trying to convert these Projects to Plugin Projects because otherwise I can't seem import plugins to the Java classes in these projects
even though I have already added these plugins as Dependencies..
So any Ideas? I am using Eclipse Modeling Tools (Luna). In tutorial they recommend using Eclipse SDK, version 3.1M5.
'Import > Existing Projects into Workspace' works for me.
For the 'root directory' choose the 'exercise1.1' directory. The two projects should then be listed in the projects list.
But these projects are 10 years old and are using the old style plugin.xml format which is not supported by default by current Eclipse builds. This results in lots of import errors.
Thanks, now it works. This is what I did.
Open plugin.xml file in the editor and Navigate to Overview Tab. There under the section Plugin Content you would find an option to Create an OSGi Bundle Manifest OR if there is no such option then a Message asking you to either write a Manifest.MF file manually or to first install Eclipse 2.0 style plugin support. (Help> Install New Software, use this update site http://download.eclipse.org/eclipse/updates/4.4). You will find 'Eclipse 2.0 Style Plugin Support' in the 'Eclipse Tests, Examples and Extras' section.
checkout this link for more info (Tools for Eclipse 2.0 plugins upgrade)
Once installed old plugins can run and also a Create OSGi Bundle Manifest option will appear under Plugin Content section if it wasn't there earlier...

How can I create a netbeans 7.3 project wrapping the jedit source code?

I thought this is an easy question because there's already a wiki topic about this here especially this section. however the wiki is out of date. A prior question exists here on Stackoverflow that only has a reference to these now out of date wiki topics. The netbeans wiki must be for some older version of NetBeans UI, and I'm using NetBeans 7.3.
If I try to use the existing sources option in 7.3 it assumes that you cannot have a build.xml already, and so it tells you you cannot proceed:
For illustration purposes it may help to show some structure of jedit source code folders.
I have both the latest jEdit source code and the 5.0 stable source code. The project layout is roughly like this:
+ jedit
|
+- org
|
+- net
|
+- test
|
+- de
|
....
I have located the folder where the root build.xml is located, but I cannot follow the wiki instructions because there does not appear to be such a project-with-existing-ant-build-script option anymore.
And Now We Try the Free-Form option... and it doesn't work either...
The free-form project works in so far is that it lets you create a netbeans project, but the scan of the directory results in a complete mess inside netbeans. A series of folders with path "." are added, 5 copies of a duplicate "." folder, and 5 duplicate "Source Packages" entries in the project tree view. This may be related to the second problem with free-form which is that it will not build and run jEdit, but dies with a strange error message that does not happen when I try to build outside netbeans:
The mess in the project pane, leaves me unable to navigate or see the source structure:
And it doesn't build:
Processing /Users/admin/NetBeansProjects/jedit/trunk/build/test/merged-reports/TESTS-TestSuites.xml to /var/folders/59/mc8gzxfn1b98j389rkz4zjsc0000gs/T/null666107982
Loading stylesheet jar:file:/Applications/NetBeans/NetBeans%207.3.app/Contents/Resources/NetBeans/java/ant/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
: Error! The first argument to the non-static Java function 'replace' is not a valid object reference.
: Error! Cannot convert data-type 'void' to 'reference'.
: Fatal Error! Could not compile stylesheet
Failed to process /Users/admin/NetBeansProjects/jedit/trunk/build/test/merged-reports/TESTS-TestSuites.xml
/Users/admin/NetBeansProjects/jedit/trunk/build.xml:442: Errors while applying transformations: Fatal error during transformation
BUILD FAILED (total time: 35 seconds)
So I gave up on the free-form project because it doesn't build.
And now on to opening a project with existing sources after removing the build folder and build.xml which doesn't work either...
If I want to import project sourcecode (just the java, no build.xml because I deleted it), I get stuck here:
What did I try to do? I tried to add the source folders, as directories under org, de and net (see the source tree I put above in my question). However netbeans automatically traverses upwards to the ROOT folder of my source code.
I am unable to select any folder OTHER than the root because selecting a folder underneath it leads to Netbeans unhelpfully always moving back up the folder hierarchy until it arrives where it wants to be. It won't be told any different.
This in turn leads to netbeans complaining about something it decided to do to me, which is that it can't include jedit/test because it's using jedit as the root source folder. Nothing I select (however many folders below jedit/) results in netbeans doing anything differently. It insists on traversing back through subdirectories in an effort to be helpful. I am beginning to think that the real world users of java may organize their source code in a way that netbeans cannot handle.
Other Information
Building from the shell with ant against the default build.xml shipping with the sources of jedit works fine, as long as you have a modern version of ant. Reinstalling ant fixed my command line build abilities.
I found that I had to install the latest ant version from the apache website before my Mac OS X box would build jEdit 5.0 at the command line. The ant version inside my netbeans app bundle may be different.
I am using OS X 10.8 and hava Java 1.5, 1.6, and 1.7 installed, currently building against java 1.6.
It seems to me that Netbeans opens Maven projects with aplomb and grace and this in turn is due to Maven projects generally following standard java directory layouts. Ant-based builds also seem to import nicely to the extent that naming and layout standards are intelligible to Netbeans, but jEdit appears to be something that Netbeans can't cleanly handle in its current form.
The URL below has instructions to setup and compile jEdit 5.0.0 source in NetBeans 7.3.
http://www.areaofthoughts.com/2013/01/compiling-running-jedit-5-in-netbeans-73.html
Summary:
jsr305-2.0.1.jar dependency must be downloaded and added manually to netbeans Libraries tab or else javax.annotation.Nonnull and javax.annotation.Nullable will not resolve.
Unpacking the jedit source code to a subdirectory 1 level underneath the folder that will be the netbeans project is essential.
The screen shot states that /Users/admin/NetBeansProject/jedit/trunk already contains a build.xml file. You should try creating a "Freeform Project" in NetBeans instead of a "New Java Project with Existing Sources".
If you don't want to reuse the existing build.xml file, you can copy your source files to a new directory. In particular, you should place them in the src subdirectory of an otherwise empty directory for the NetBeans project. Then you can create a "New Java Project with Existing Sources." You shouldn't need to create your own Ant build file unless you need to add custom tasks or customize the default ones which are generated by NetBeans.
I can't comment on using Netbeans for Java, as I code PHP with it only. But when loading a project with existing PHP sources, I can save my project configuration file in the project or at another location (and I do sometimes save the project config to my windows profile, as the sources are on a samba share on my linux web server)

How to include a Java project in an Android project?

I am using Eclipse to develop an Android board game.
I have developed the UI in an Android project.
On the other hand, I have developed the AI in a regular Java project, because I wanted to be able to test it without all the constraints of the Android emulator (I didn't find any other way to run the code using my Windows JVM).
Now comes the times when I want to 'join' both projects (which work fine independently), that is to use the AI Java classes from the UI.
This is what I have tried:
In my Android project Properties > Projects References, I ticked the Java project.
This allows me to build without error the Android project (which instantiates an AI object).
But it fails at runtime with this error:
Could not find class 'my.package.AI', referenced from method my.otherpackage.UI.onStart
What would be the correct way to include the AI Java Project into my Android Project ?
(NB: I still want to be able to develop and test the AI as a regular Java app, so I think using a jar or copying all the sources to the Android Project would not suit my needs)
EDIT:
I was hoping that the new ADT v17 would solve the problem, but it didn't. I have tried virtually every option available to include a project in my Android project:
Adding or linking a source folder
Adding a Project (Java Build Path > Projects tab)
Adding a Class Folder or a Library (Java Build Path > Library tab)
Ticking all the previously imported projets/libraries as Exported
The only way that allows compiling and running without error is adding the JAR of the Java Project to the Android project build path.
Projects References only add the dependent project source code (your AI project) as a soft (perhaps weak is a more accurate word) reference, your AI project is not added into you Android Project Build path. so the actual ai.jar is not exported into the final apk when Eclipse build your app.
You should add AI project into Android project build path:
Right-click on your android project, select Build Path - Configure Build Path, in Projects tab (Required projects on the build path), add your AI project here.
Then in Order and Export tab (Build class path order and exported entries), tick your newly added AI project appeared int the list.
Step 2 is probably optional, this should add AI project as a reference in Android project and export the ai.jar to final.apk when Eclipse build your Android project.
Update from ADT 17.0.0:
Android Dev Team just release SDK r17 with ADT 17.0.0, which claims to handle this use cases properly now:
Eclipse specific changes
The dynamic classpath container called “Library Projects” has been renamed to “Android Dependencies” as it now contains more than just Library Projects.
The container will now also be populated with Java-only projects that are referenced by Library Projects. If those Java projects also reference other Java projects and/or jar files they will be added automatically (jar files referenced through user libraries are supported as well).
Important: this only happens if the references are set to be exported in the referencing project. Note that this is not the default when adding a project or jar file to a project build path.
Library Projects (and the content of their libs/*.jar files) is always exported. This change only impacts Java-only projects and their own jar files.
Again, duplicates (both projects and jar files) are detected and removed.
More in this link.
Edit: After much testing, reading and found my solution. Problem is (as of this writing) that you can't reference another project from an Android project, although it works fine for a normal Java application project.
Workaround for me (Windows with NTFS filesystem):
In a prompt (admin rights) make a symbolic folder link using mklink /D command pointing to your source project folders, and refresh in Eclipse as needed.
The obvious limitation is you cant use the same package names in source project and target project, and then there is the problem with libs in the common project.
example:
cd \java\workspace\AndroidProject\src\your\package
mklink /D common c:\java\workspace\CommonProject\src\your\package\common
Clarification: You can reference another project from an Android project to make it compile, however when you run, the referenced classes from the included project are not put in the apk classes.dex (verified with dex decompiler).
Using ADT 21.0.0 64bit on Windows 7 64bit. I tried adding project to build path. Ticked in the Order and Export, played with order. I read the official solution, the detailed explanation of that solution, exported as JAR, added to libs. Did not work, while the source was without errors. Read in the comments that the solution didn't work for everyone.
Was fed up with it and tried a simple but somewhat messier solution: linked the Java project's source to the Android project. That did the trick. Hope that this will help others too.
Don't add it to the project references area, instead go into the Android pane (in the Project Properties), scroll down to the bottom, and add it under Libraries.
This sometimes works but sometimes produces bizarre Eclipse issues (not sure why), in which case copying the jar directly into the project seems to work best.

Your active platform is: JDK_1.6, but the corresponding property "platforms.JDK_1.6.home" is not found in the project's properties files

I'm a Java noob (but have been programming for 25+ years, and have worked with OO languages from day 1).
All of a sudden I started getting this error:
Your active platform is: JDK_1.6, but the corresponding property "platforms.JDK_1.6.home" is not found in the project's properties files.
Not sure what caused this condition, and not sure what Java's asking me to do. I'm working in the NetBeans IDE. The last thing I attempted to do is add some binary (image) resources to my project.
In my case the JDK setup in Netbeans was fine. It was just one of those strange Netbeans issues that come out of nowhere.
My fix was:
Clear the Netbeans Cache i.e. delete the folder:
C:\Users\\AppData\Local\NetBeans\Cache\
It means you haven't told netbeans where your Java 1.6 installation is. Go into settings, add the JDK (JDK->Add->New), and select the directory above 'bin' for your JDK16.
This error can occur at two scenarios:
Right click your netbean project -> Properties -> Libraries
After select Libraries , right panel on top you can see "Java Platform" combo box. This Jave Platform is missing for your project. You need to add using Manage Platforms bottom beside Jave Platform combo box.
Even thought scenario (1) is correct it can happen. Because your project has reference to another netbean project in your Libraries. This reference project is missing Jave Platform.
I have Linux in my office and Mac in Home and this problem is frequently when I share projects in github, I solve it removing the build directory and doing clean and build.
Right click on project - Properties - Libraries - Select the correct jdk version from the Java Platform combobox.
NetBeans bug
If your project depends on other projects, open and clean build all of them(that fixed it for me).
Most likely cache-related stuff. Clean up NB cache as suggested by someone before
You should remove the files under private folder in the nbproperties folders.
for me any recommended way early didn't helped, but changing in project Properties -> Source/Binary format to JDK 7, Save than change back to JDK 8 fixed this error

Categories