Importing Java libraries in Netbeans on Linux
When I found myself re-adding libraries in Netbeans again, I felt that I needed a quicker way to so. I have plenty of java libraries installed on my machine and it’s turning into a real hassle to set them up each time I clean out my Netbeans configuration folder.
So, that is why I created this script.
It is somewhat meant to be used on Gentoo. But it can be used on other distros too.
The easiest way to explain it’s features is to just give you the manual:
(You can find the complete source here: nopaste
NAME
./nb-importlib.sh - Imports a system java library into a netbeans installation
SYNOPSIS
./nb-importlib.sh [OPTION] [NAME]
DESCRIPTION
This script will import a system java library into a netbeans installation.
If ran on gentoo, --gentoo is selected by default. You can use '-n' or
'--no-gentoo' to disable and set the library up manually.
OPTIONS
-t, --target
The netbeans target folder. uses "~/.netbeans/dev/" by default.
-r, --dry-run
Only output the xml file to the screen. Don't write anywhere.
-f, --force
Do not prompt before overwriting.
-g, --gentoo
Use java-config-2 to get the information.
Enabling the gentoo mode will disable the use of '--description',
'--classpath', '--javadoc' and '--source'.
-n, --no-gentoo
Disable the use of java-config-2 and only use manually provided
information.
-d, --description
Use this alternate description.
-c, --classpath=RESOURCES
Set the classpath to RESOURCES (separated by a comma or colon).
-j, --javadoc=JAVADOCS
Set the javadocs to JAVADOCS (separated by a comma or a colon).
-s, --source=SOURCES
Set the sources to SOURCES (separated by a comma or a colon).
-m, --maven-pom=MAVEN-POM
Set the maven-pom resources to MAVEN-POM
(separated by a comma or a colon).
LIBRARY
To use the functionality without java-config-2 or alter it, you can use
or alter the functionality provided in the script.
Following 2 functions are provided:
* function print_library( , , > ...);
- Name of the library to be displayed in netbeans.
- Short description of the library.
- Different volumes to add (separated by a single space).
A volume can be specified in the format: =
- The following volume types are allowed:
classpath src javadoc maven-pom
- Resources are to be separated by ':' or ','.
* function print_volume( , );
- The type of the volume.
Possible values are:
classpath src javadoc maven-pom
- A list of resources to add.
Resources are to be separated by ':' or ','.
AUTHOR
Written by Jan Vansteenkiste
SEE ALSO
java-config, java-config-2
REPORTING BUGS
Report bugs to http://vstone.eu/tag/nb-importlib/
You can get the source of this script here: nb-importlib
Notes:
- For some reason, you can NOT use spaces in the name of your Library. Why? Adding libraries with a custom name with spaces will work just up till the point when you try to use them in a project. After that, you’ll get a unresolved reference warning. We can pin point the problem in your project.properties file, where the reference to the library is stored. Other libraries that are not manually added don’t tend to have the problem and get referenced by a alternative name.
- If you are using Gentoo and you already upgraded to OpenRC, you’ll have to modify the script a little bit or you won’t be able to use any of the built in Gentoo functionality. Change all references (2) to /sbin/functions.sh and change them into /etc/init.d/functions.sh.