Discussion:
Installing the POI jars for Netbeans
Dave Coventry
2009-12-13 12:44:26 UTC
Permalink
Hi,

I've downloaded the poi-3.5-FINAL jars and placed them in
/usr/share/java on my Ubuntu Karmic test machine. I have also copied
them to the same directory of my app.

My app declares "import org.apache.poi.hpsf.*;", but Netbeabs says
that "ipackage org.apache.poi.hpsf does not exist".

How can I rectify this?

Once I have my app working, I'm planning on putting it on a production
machine which has Debian Lenny installed.

Many Thanks,

Dave Coventry
Dave Coventry
2009-12-13 16:46:37 UTC
Permalink
I really can't think of anything else to try.

I'm loading more and more stuff onto the machine and I'm pretty sure
that this is not the way to go as I'm probably going to get conflicts
and the installation is going to break.
Post by Dave Coventry
Hi,
I've downloaded the poi-3.5-FINAL jars and placed them in
/usr/share/java on my Ubuntu Karmic test machine. I have also copied
them to the same directory of my app.
My app declares "import org.apache.poi.hpsf.*;", but Netbeabs says
that "ipackage org.apache.poi.hpsf does not exist".
How can I rectify this?
Once I have my app working, I'm planning on putting it on a production
machine which has Debian Lenny installed.
Many Thanks,
Dave Coventry
Hannes Erven
2009-12-13 17:45:27 UTC
Permalink
Dave,
Post by Dave Coventry
My app declares "import org.apache.poi.hpsf.*;", but Netbeabs says
that "ipackage org.apache.poi.hpsf does not exist".
most probably you'll need to add the libraries to the project's class
path in NetBeans. The install location (whether the app lib, your home
dir, or /usr/share/...) does not matter as long as the project is
correctly configured.

I'm not familiar with NetBeans, but I guess this link will help you
configure your project:
http://javahowto.blogspot.com/2006/06/set-classpath-in-eclipse-and-netbeans.html



-hannes
Dave Coventry
2009-12-13 18:35:21 UTC
Permalink
Hannes,

Thanks for taking the time to help.

I'd already seen the link but I added the jar files to the Run tab. It
was only when I added it to the Compile tab that it worked.

I have a feeling I'm going to find it difficult to imp[lement on my
Debian Production system.

Thanks again,

Dave
Hannes Erven
2009-12-13 22:13:38 UTC
Permalink
Dave,
Post by Dave Coventry
I have a feeling I'm going to find it difficult to imp[lement on my
Debian Production system.
It might actually be easier for you to get the final program running
that to configure NetBeans to do what you want ;-)

If you have any issues, post back. Most probably anyone a bit familiar
with Java will be able to help you.


As a first hint, be sure to include the -classpath option in your call
to java with the POI jar in it, e.g.

java -classpath ".:/path/to/poi.jar:/any/other/path/otherlib.jar"
your.programs.class

or put the jar in the same folder as your program's binaries (that is,
on the same level as the "your" folder in the above example).


Best regards,

-hannes
MSB
2009-12-14 07:41:31 UTC
Permalink
Morning Dave,

Must admit that I use Netbeans all of the time and I just want to ask a
couple of questions to bve clear about what you are asking.

Firstly, can I assume that you now have the IDE set up so that you can build
and test your project within Netbeans?
Secondly, have you created a project for your application?

If the answer to both of these questions is 'yes' and all that you are
concerned about now is deploying the application, then take a look in the
dist sub-folder of your project folder. There, you will find a file called
readme.txt that explains what you need to do to distribute the application.
I have pasted into this message the contents of the readme file from a very
simple test application;

========================
BUILD OUTPUT DESCRIPTION
========================

When you build an Java application project that has a main class, the IDE
automatically copies all of the JAR
files on the projects classpath to your projects dist/lib folder. The IDE
also adds each of the JAR files to the Class-Path element in the application
JAR files manifest file (MANIFEST.MF).

To run the project from the command line, go to the dist folder and
type the following:

java -jar "rowstyle.jar"

To distribute this project, zip up the dist folder (including the lib
folder)
and distribute the ZIP file.

Notes:

* If two JAR files on the project classpath have the same name, only the
first
JAR file is copied to the lib folder.
* Only JAR files are copied to the lib folder.
If the classpath contains other types of files or folders, none of the
classpath elements are copied to the lib folder. In such a case,
you need to copy the classpath elements to the lib folder manually after the
build.
* If a library on the projects classpath also has a Class-Path element
specified in the manifest,the content of the Class-Path element has to be on
the projects runtime path.
* To set a main class in a standard Java project, right-click the project
node
in the Projects window and choose Properties. Then click Run and enter the
class name in the Main Class field. Alternatively, you can manually type the
class name in the manifest Main-Class element.

As Hannes indicated, I think that your problems are centered around the
-classpath; it 'tells' the runtime environment where to search for, find and
load the necessary resources at runtime (bet you knew that already, sorry).

Yours

Mark B
Post by Dave Coventry
Hannes,
Thanks for taking the time to help.
I'd already seen the link but I added the jar files to the Run tab. It
was only when I added it to the Compile tab that it worked.
I have a feeling I'm going to find it difficult to imp[lement on my
Debian Production system.
Thanks again,
Dave
---------------------------------------------------------------------
--
View this message in context: http://old.nabble.com/Installing-the-POI-jars-for-Netbeans-tp26765779p26773995.html
Sent from the POI - User mailing list archive at Nabble.com.
Dave Coventry
2009-12-14 09:06:58 UTC
Permalink
Hi Mark,

I've set up as a project, but my interest is in the single *.java file
that I'm planning to implement on the production machine.

Basically I want the Netbeans IDE to do my debugging as I go along
(which, as I last dabbled in Java some eight or nine years ago, I'm
finding very useful).

Thanks very much for the tips.

- Dave
Post by MSB
Morning Dave,
Must admit that I use Netbeans all of the time and I just want to ask a
couple of questions to bve clear about what you are asking.
Firstly, can I assume that you now have the IDE set up so that you can build
and test your project within Netbeans?
Secondly, have you created a project for your application?
If the answer to both of these questions is 'yes' and all that you are
concerned about now is deploying the application, then take a look in the
dist sub-folder of your project folder. There, you will find a file called
readme.txt that explains what you need to do to distribute the application.
I have pasted into this message the contents of the readme file from a very
simple test application;
========================
BUILD OUTPUT DESCRIPTION
========================
When you build an Java application project that has a main class, the IDE
automatically copies all of the JAR
files on the projects classpath to your projects dist/lib folder. The IDE
also adds each of the JAR files to the Class-Path element in the application
JAR files manifest file (MANIFEST.MF).
To run the project from the command line, go to the dist folder and
java -jar "rowstyle.jar"
To distribute this project, zip up the dist folder (including the lib
folder)
and distribute the ZIP file.
* If two JAR files on the project classpath have the same name, only the
first
JAR file is copied to the lib folder.
* Only JAR files are copied to the lib folder.
If the classpath contains other types of files or folders, none of the
classpath elements are copied to the lib folder. In such a case,
you need to copy the classpath elements to the lib folder manually after the
build.
* If a library on the projects classpath also has a Class-Path element
specified in the manifest,the content of the Class-Path element has to be on
the projects runtime path.
* To set a main class in a standard Java project, right-click the project
node
in the Projects window and choose Properties. Then click Run and enter the
class name in the Main Class field. Alternatively, you can manually type the
class name in the manifest Main-Class element.
As Hannes indicated, I think that your problems are centered around the
-classpath; it 'tells' the runtime environment where to search for, find and
load the necessary resources at runtime (bet you knew that already, sorry).
Yours
Mark B
Post by Dave Coventry
Hannes,
Thanks for taking the time to help.
I'd already seen the link but I added the jar files to the Run tab. It
was only when I added it to the Compile tab that it worked.
I have a feeling I'm going to find it difficult to imp[lement on my
Debian Production system.
Thanks again,
Dave
---------------------------------------------------------------------
--
View this message in context: http://old.nabble.com/Installing-the-POI-jars-for-Netbeans-tp26765779p26773995.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
MSB
2009-12-15 07:50:43 UTC
Permalink
Hello Dave,

I thought about this overnight because I did not want what I say next to
sound really patronising; anyway, here goes.

When you deploy the application you are working on, you will not deploy the
.java file as it contains the source code you have created. Rather, you will
deploy the .class file which contains the pre-compiled bytecode that the JVM
will load, compile into native code and then run. Also, you will need to
make sure that the machine upon which your application runs has access to
the POI archives because the JVM needs to locate, load and run one or more
of the classes it contains. I am sure you knew all of this and that is why I
worried about it sounding patronising, but when you said in you last message
that you interest was in a single .java file that you planned to implement
on another machine, I worried a bit.

Now, one of the easiest ways to achieve all of this is to use the contents
of the dist sub-folder that Netbeans will create for you. It will create an
archive that contains your class and ensure that the other archives your
application needs are copied into it's lib sub-folder. All you then need to
do is copy this over to the host machone and your application ought to run.
Of course, you do not have to use this structure and there are good reasons
not to do so; you can copy the POI archive into a different folder even on
another machine as long as you ensure that it is accessible to your
application at runtime. It is quite likely that you will need to set the
-classpath environment variable to ensure that the JVM can locate the
resources it requires at runtime. I work almost exclusivly on Windows and
use .bat files (batch files) extensively to run applications as they allow
me to create instructions such as this;

"C:\Program Files\Java\jre1.6.0_07\bin\java" -classpath ".;..;" -jar
"C:\Work Area\Programming\Java\Development\Netbeans\Neat\File
Processor\dist\File_Processor.jar"

and set the -classpath the application uses when it is executed. Sadly, I do
not know if such a mechanism exists on Linux but suspect that it does.

Yours

Mark B
Post by Dave Coventry
Hi Mark,
I've set up as a project, but my interest is in the single *.java file
that I'm planning to implement on the production machine.
Basically I want the Netbeans IDE to do my debugging as I go along
(which, as I last dabbled in Java some eight or nine years ago, I'm
finding very useful).
Thanks very much for the tips.
- Dave
Post by MSB
Morning Dave,
Must admit that I use Netbeans all of the time and I just want to ask a
couple of questions to bve clear about what you are asking.
Firstly, can I assume that you now have the IDE set up so that you can build
and test your project within Netbeans?
Secondly, have you created a project for your application?
If the answer to both of these questions is 'yes' and all that you are
concerned about now is deploying the application, then take a look in the
dist sub-folder of your project folder. There, you will find a file called
readme.txt that explains what you need to do to distribute the application.
I have pasted into this message the contents of the readme file from a very
simple test application;
========================
BUILD OUTPUT DESCRIPTION
========================
When you build an Java application project that has a main class, the IDE
automatically copies all of the JAR
files on the projects classpath to your projects dist/lib folder. The IDE
also adds each of the JAR files to the Class-Path element in the application
JAR files manifest file (MANIFEST.MF).
To run the project from the command line, go to the dist folder and
java -jar "rowstyle.jar"
To distribute this project, zip up the dist folder (including the lib
folder)
and distribute the ZIP file.
* If two JAR files on the project classpath have the same name, only the
first
JAR file is copied to the lib folder.
* Only JAR files are copied to the lib folder.
If the classpath contains other types of files or folders, none of the
classpath elements are copied to the lib folder. In such a case,
you need to copy the classpath elements to the lib folder manually after the
build.
* If a library on the projects classpath also has a Class-Path element
specified in the manifest,the content of the Class-Path element has to be on
the projects runtime path.
* To set a main class in a standard Java project, right-click the project
node
in the Projects window and choose Properties. Then click Run and enter the
class name in the Main Class field. Alternatively, you can manually type the
class name in the manifest Main-Class element.
As Hannes indicated, I think that your problems are centered around the
-classpath; it 'tells' the runtime environment where to search for, find and
load the necessary resources at runtime (bet you knew that already, sorry).
Yours
Mark B
Post by Dave Coventry
Hannes,
Thanks for taking the time to help.
I'd already seen the link but I added the jar files to the Run tab. It
was only when I added it to the Compile tab that it worked.
I have a feeling I'm going to find it difficult to imp[lement on my
Debian Production system.
Thanks again,
Dave
---------------------------------------------------------------------
--
http://old.nabble.com/Installing-the-POI-jars-for-Netbeans-tp26765779p26773995.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
--
View this message in context: http://old.nabble.com/Installing-the-POI-jars-for-Netbeans-tp26765779p26790941.html
Sent from the POI - User mailing list archive at Nabble.com.
Dave Coventry
2009-12-15 14:06:19 UTC
Permalink
Hi Mark,
Post by MSB
I thought about this overnight because I did not want what I say next to
sound really patronising; anyway, here goes.
It's not a problem. I realise that there is always a possibility that
I could be a recognised computer science professor with thirty years
of working at the cutting edge under my belt, but you can rest
assured, this is not the case!
Post by MSB
When you deploy the application you are working on, you will not deploy the
.java file as it contains the source code you have created. Rather, you will
deploy the .class file which contains the pre-compiled bytecode that the JVM
will load, compile into native code and then run. Also, you will need to
make sure that the machine upon which your application runs has access to
the POI archives because the JVM needs to locate, load and run one or more
of the classes it contains. I am sure you knew all of this and that is why I
worried about it sounding patronising, but when you said in you last message
that you interest was in a single .java file that you planned to implement
on another machine, I worried a bit.
Not to worry.

The other machine is a headless Debian box which will not be able to
have Netbeans installed.

Once I can be sure that the Java code is good, I'll copy it across to
the production machine and compile it there.

The reason I posted on here was that I couldn't be sure that my java
code had access to the jar libraries it needed; once I can move it on
the Production machine I shall be reasonably confident that it should
run, given access to the relevant libraries.

I will obviously make sure that these libraries are accessible to the code.
Post by MSB
Now, one of the easiest ways to achieve all of this is to use the contents
of the dist sub-folder that Netbeans will create for you. It will create an
archive that contains your class and ensure that the other archives your
application needs are copied into it's lib sub-folder. All you then need to
do is copy this over to the host machone and your application ought to run.
That's great news; I shall definitely give that a go.
Post by MSB
Of course, you do not have to use this structure and there are good reasons
not to do so; you can copy the POI archive into a different folder even on
another machine as long as you ensure that it is accessible to your
application at runtime. It is quite likely that you will need to set the
-classpath environment variable to ensure that the JVM can locate the
resources it requires at runtime. I work almost exclusivly on Windows and
use .bat files (batch files) extensively to run applications as they allow
me to create instructions such as this;
"C:\Program Files\Java\jre1.6.0_07\bin\java" -classpath ".;..;" -jar
"C:\Work Area\Programming\Java\Development\Netbeans\Neat\File
Processor\dist\File_Processor.jar"
and set the -classpath the application uses when it is executed. Sadly, I do
not know if such a mechanism exists on Linux but suspect that it does.
Yes it doe. I shall certainly try to implement it when I get my app working.

Thanks again,

Dave Coventry
Dave Coventry
2009-12-24 13:18:51 UTC
Permalink
Hi Mark,
Post by MSB
Now, one of the easiest ways to achieve all of this is to use the contents
of the dist sub-folder that Netbeans will create for you. It will create an
archive that contains your class and ensure that the other archives your
application needs are copied into it's lib sub-folder.
It seems I was a little overoptimistic.

I have written the Java code without error.

However, I am unable to generate the dist subfolder tha you mention.

Nether can I get it to create an archive with my class and the other archives.
MSB
2009-12-24 16:37:06 UTC
Permalink
Hello again Dave,

Sorry to hear you are still running into problems with Netbeans but this one
does sound like it might be a simple fix; famous last words?

I think that you need to check and modify your project properties. To do
this in 'my' version of Netbeans - I am currently using 6.5.1 - you need to
do the following;

Open Netbeans.
Open the project.
Click on 'Run' and from the drop down menu select the 'Set Project
Configuration' option.
This will open another sub-menu on which there are two choices. The first is
will be something like '<default config>' and the second will be
'Customize'.
Select the 'Customize' option and this will open up the 'Project Properties'
screen for you. Look into the left hand pane that will be headed
'Categories' and select the 'Packaging' option. If this option does not show
up then it is likely hidden under the 'Build' option in the tree amd you can
expand that by clicking on the plus sign that will be to the left of the
word 'Build'.
Once you have selected 'Packaging', you should see over in the right hand
portion of the screen a selection box that says something like 'Build JAR
After Compiling'. Make sure that this option is selected and then OK your
way out.

With luck, when you choose either to 'Build the Project' or 'Clean and Build
the Project' from the 'Run' menu again, the distribution should be built for
you.

Yours

Mark B
Post by Dave Coventry
Hi Mark,
Post by MSB
Now, one of the easiest ways to achieve all of this is to use the contents
of the dist sub-folder that Netbeans will create for you. It will create an
archive that contains your class and ensure that the other archives your
application needs are copied into it's lib sub-folder.
It seems I was a little overoptimistic.
I have written the Java code without error.
However, I am unable to generate the dist subfolder tha you mention.
Nether can I get it to create an archive with my class and the other archives.
---------------------------------------------------------------------
--
View this message in context: http://old.nabble.com/Installing-the-POI-jars-for-Netbeans-tp26765779p26915454.html
Sent from the POI - User mailing list archive at Nabble.com.
Dave Coventry
2009-12-26 08:12:39 UTC
Permalink
Golly, Mike! Replying on Christmas eve?

We've both of us got to get a life!

Thanks for the instructions, by the way; worked a treat!
MSB
2009-12-26 08:18:44 UTC
Permalink
There is a much more straightforward way to get to the Project Properties
screen. Simply;

Open NetBeans
Open the project.
Click on the File menu and from the drop down musn that opens select the
Project Properties option.

Then you can proceed as described in my previous message. Also, I forgot to
mention the 'Exclude From JAR File' field; I guess that it is obvious what
this fileds funtion is but I did not mention what to put into it. I use a
simple regex that looks like this - **/*.java,**/*.form - and I cannot claim
any credit for authorship, this is simply the default that NetBeans created
for me when I began using the package. I am guessing that you may need to
enter it manually after checking the Build JAR after Compiling check box.
Finally, the name of the JAR file should be defaulted into the top field as
it is not editable. I cannot believe that there is another location
somewhere that allows you to specify the folder the archive ought to be
created in; and of course the name of the JAR will be taken from the package
statement or location you specified for the project.

Hope this helps.

Yours

Mark B
Post by Dave Coventry
Hi Mark,
Post by MSB
Now, one of the easiest ways to achieve all of this is to use the contents
of the dist sub-folder that Netbeans will create for you. It will create an
archive that contains your class and ensure that the other archives your
application needs are copied into it's lib sub-folder.
It seems I was a little overoptimistic.
I have written the Java code without error.
However, I am unable to generate the dist subfolder tha you mention.
Nether can I get it to create an archive with my class and the other archives.
---------------------------------------------------------------------
--
View this message in context: http://old.nabble.com/Installing-the-POI-jars-for-Netbeans-tp26765779p26925910.html
Sent from the POI - User mailing list archive at Nabble.com.
Loading...