NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
software visualization Posted via mailing list.
|
Posted: Fri Jun 27, 2008 3:48 pm Post subject: building wipes out directory |
|
|
New to netbeans....
I have a directory (images) which contains .png files. I refer to this directory in my program. Since it contains images I load at runtime and no .java files, I put it under build-->classes--myProject so the path is build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images directory.
I've tried telling NB not to do this through properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has an obvious solution I am overlooking.
Many thanks. |
|
| Back to top |
|
 |
Thomas Wolf Posted via mailing list.
|
Posted: Fri Jun 27, 2008 3:57 pm Post subject: building wipes out directory |
|
|
The 'build' directory is for "building", not where you want to put source (java files, pngs, etc. are "sources" for the build). You could put the png files in your source tree in the same package structure as your java files (e.g. "com/company/product/resources/icons/") - or anywhere else under your source tree..but I guess, then you would have to modify the build script to put them wherever you can reliably find them at runtime.
tom
software visualization wrote: | Quote: | New to netbeans....
I have a directory (images) which contains .png files. I refer to this directory in my program. Since it contains images I load at runtime and no .java files, I put it under build-->classes--myProject so the path is build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images directory.
I've tried telling NB not to do this through properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has an obvious solution I am overlooking.
Many thanks.
|
|
|
| Back to top |
|
 |
Ian Carter Posted via mailing list.
|
Posted: Fri Jun 27, 2008 4:08 pm Post subject: building wipes out directory |
|
|
What you are telling NetBeans when you "clean and build" is to delete the
build area and re-create it by builing your classes.
So, yes, all files in that area will be deleted.
Ian
________________________________
From: software visualization
[mailto:softwarevisualization@gmail.com]
Sent: 27 June 2008 16:48
To: nbusers@netbeans.org
Subject: [nbusers] building wipes out directory
New to netbeans....
I have a directory (images) which contains .png files. I refer to
this directory in my program. Since it contains images I load at runtime and
no .java files, I put it under build-->classes--myProject so the path is
build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images directory.
I've tried telling NB not to do this through
properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has an obvious
solution I am overlooking.
Many thanks. |
|
| Back to top |
|
 |
software visualization Posted via mailing list.
|
Posted: Fri Jun 27, 2008 4:46 pm Post subject: building wipes out directory |
|
|
OK so I am used to putting these kinds of non-compilable (i.e. non .java files) resources in the directory which contains the class files, since that is supposedly on the classpath and where java looks for things at runtime. So I looked to see where NB puts .class files (where they end up when the source is compiled) and that was the "build folder". I placed the images directory there for that reason.
To me "build" means, essentially "compile the project classes, resolving dependencies, and place them where it is you (NB) place them.. probably some sensible default "place" which ultimately is configurable in some way which I'll learn about later.....".
So I had no reason to believe that an "images" folder would "end up" anywhere useful if it and its contents existed in my sources. That, at least, is what happens if you put an image folder containing just images in your source directory using javac from the command line and some other IDEs.
So now that I've laid out my primitive interpretation - in gory detail - of what it means to "build" something what is it I need to get acquainted with so that my understanding and reality start to look like each other?
Many thanks.
On Fri, Jun 27, 2008 at 12:07 PM, Ian Carter <iccarter@gotadsl.co.uk (iccarter@gotadsl.co.uk)> wrote:
| Quote: | What you are telling NetBeans when you "clean and build" is to delete the
build area and re-create it by builing your classes.
So, yes, all files in that area will be deleted.
Ian
________________________________
From: software visualization
[mailto:softwarevisualization@gmail.com (softwarevisualization@gmail.com)]
Sent: 27 June 2008 16:48
To: nbusers@netbeans.org (nbusers@netbeans.org)
Subject: [nbusers] building wipes out directory
New to netbeans....
I have a directory (images) which contains .png files. I refer to
this directory in my program. Since it contains images I load at runtime and
no .java files, I put it under build-->classes--myProject so the path is
build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images directory.
I've tried telling NB not to do this through
properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has an obvious
solution I am overlooking.
Many thanks.
|
|
|
| Back to top |
|
 |
Jay Foster Posted via mailing list.
|
Posted: Fri Jun 27, 2008 4:57 pm Post subject: building wipes out directory |
|
|
I include all artifacts (compilable or not) in my source folder(s). If
you really need to put noncompilable artifacts in your build directory
then you probably could override the default clean target of the
build-impl ant file such that you define a fileset with an include
and/or exclude specification to keep the stuff you want and delete the
rest.
Jay
On Fri, 2008-06-27 at 12:46 -0400, software visualization wrote:
| Quote: | OK so I am used to putting these kinds of non-compilable (i.e.
non .java files) resources in the directory which contains the class
files, since that is supposedly on the classpath and where java looks
for things at runtime. So I looked to see where NB puts .class files
(where they end up when the source is compiled) and that was the
"build folder". I placed the images directory there for that reason.
To me "build" means, essentially "compile the project classes,
resolving dependencies, and place them where it is you (NB) place
them.. probably some sensible default "place" which ultimately is
configurable in some way which I'll learn about later.....".
So I had no reason to believe that an "images" folder would "end up"
anywhere useful if it and its contents existed in my sources. That, at
least, is what happens if you put an image folder containing just
images in your source directory using javac from the command line and
some other IDEs.
So now that I've laid out my primitive interpretation - in gory detail
- of what it means to "build" something what is it I need to get
acquainted with so that my understanding and reality start to look
like each other?
Many thanks.
On Fri, Jun 27, 2008 at 12:07 PM, Ian Carter <iccarter@gotadsl.co.uk>
wrote:
What you are telling NetBeans when you "clean and build" is to
delete the
build area and re-create it by builing your classes.
So, yes, all files in that area will be deleted.
Ian
________________________________
From: software visualization
[mailto:softwarevisualization@gmail.com]
Sent: 27 June 2008 16:48
To: nbusers@netbeans.org
Subject: [nbusers] building wipes out directory
New to netbeans....
I have a directory (images) which contains .png files.
I refer to
this directory in my program. Since it contains images I load
at runtime and
no .java files, I put it under build-->classes--myProject so
the path is
build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images
directory.
I've tried telling NB not to do this through
properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has
an obvious
solution I am overlooking.
Many thanks.
|
|
|
| Back to top |
|
 |
Bayless Kirtley Posted via mailing list.
|
Posted: Fri Jun 27, 2008 5:48 pm Post subject: building wipes out directory |
|
|
Actually, I think Netbeans expects you to run from the jar file rather than the class files. The build directory structure is not on the run classpath at all. I keep images and other miscellaneous runtime stuff in a directory under the project tree, parallel with the dist directory. For simplicity, I just hard code the path to these within my source, eg. "../images/xxx".. It works well for me that way.
Bayless
| Quote: | ----- Original Message -----
From: software visualization (softwarevisualization@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Friday, June 27, 2008 11:46 AM
Subject: Re: [nbusers] building wipes out directory
OK so I am used to putting these kinds of non-compilable (i.e. non .java files) resources in the directory which contains the class files, since that is supposedly on the classpath and where java looks for things at runtime. So I looked to see where NB puts .class files (where they end up when the source is compiled) and that was the "build folder". I placed the images directory there for that reason.
To me "build" means, essentially "compile the project classes, resolving dependencies, and place them where it is you (NB) place them.. probably some sensible default "place" which ultimately is configurable in some way which I'll learn about later.....".
So I had no reason to believe that an "images" folder would "end up" anywhere useful if it and its contents existed in my sources. That, at least, is what happens if you put an image folder containing just images in your source directory using javac from the command line and some other IDEs.
So now that I've laid out my primitive interpretation - in gory detail - of what it means to "build" something what is it I need to get acquainted with so that my understanding and reality start to look like each other?
Many thanks.
On Fri, Jun 27, 2008 at 12:07 PM, Ian Carter <iccarter@gotadsl.co.uk (iccarter@gotadsl.co.uk)> wrote:
| Quote: | What you are telling NetBeans when you "clean and build" is to delete the
build area and re-create it by builing your classes.
So, yes, all files in that area will be deleted.
Ian
________________________________
From: software visualization
[mailto:softwarevisualization@gmail.com (softwarevisualization@gmail.com)]
Sent: 27 June 2008 16:48
To: nbusers@netbeans.org (nbusers@netbeans.org)
Subject: [nbusers] building wipes out directory
New to netbeans....
I have a directory (images) which contains .png files. I refer to
this directory in my program. Since it contains images I load at runtime and
no .java files, I put it under build-->classes--myProject so the path is
build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images directory.
I've tried telling NB not to do this through
properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has an obvious
solution I am overlooking.
Many thanks.
|
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.101 / Virus Database: 270.4.1/1522 - Release Date: 6/27/2008 8:27 AM
|
|
|
| Back to top |
|
 |
software visualization Posted via mailing list.
|
Posted: Fri Jun 27, 2008 6:35 pm Post subject: building wipes out directory |
|
|
QUOTE The build directory structure is not on the run classpath at all.END_QUOTE
I think this means I understand so little, I don't even know what I don't understand. If the build directory with its .class files isn't where the result f a the build goes, then where does that result go and what is the build directory?
Obviously I'm just at sea here... time to buy a book on the subject... many thanks to everyone who replied.
sincerely.
On Fri, Jun 27, 2008 at 1:48 PM, Bayless Kirtley <bkirt@cox.net (bkirt@cox.net)> wrote:
| Quote: | Actually, I think Netbeans expects you to run from the jar file rather than the class files. The build directory structure is not on the run classpath at all. I keep images and other miscellaneous runtime stuff in a directory under the project tree, parallel with the dist directory. For simplicity, I just hard code the path to these within my source, eg. "../images/xxx".. It works well for me that way.
Bayless
| Quote: |
----- Original Message -----
From: software visualization (softwarevisualization@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Friday, June 27, 2008 11:46 AM
Subject: Re: [nbusers] building wipes out directory
OK so I am used to putting these kinds of non-compilable (i.e. non .java files) resources in the directory which contains the class files, since that is supposedly on the classpath and where java looks for things at runtime. So I looked to see where NB puts .class files (where they end up when the source is compiled) and that was the "build folder". I placed the images directory there for that reason.
To me "build" means, essentially "compile the project classes, resolving dependencies, and place them where it is you (NB) place them.. probably some sensible default "place" which ultimately is configurable in some way which I'll learn about later.....".
So I had no reason to believe that an "images" folder would "end up" anywhere useful if it and its contents existed in my sources. That, at least, is what happens if you put an image folder containing just images in your source directory using javac from the command line and some other IDEs.
So now that I've laid out my primitive interpretation - in gory detail - of what it means to "build" something what is it I need to get acquainted with so that my understanding and reality start to look like each other?
Many thanks.
On Fri, Jun 27, 2008 at 12:07 PM, Ian Carter <iccarter@gotadsl.co.uk (iccarter@gotadsl.co.uk)> wrote:
| Quote: | What you are telling NetBeans when you "clean and build" is to delete the
build area and re-create it by builing your classes.
So, yes, all files in that area will be deleted.
Ian
________________________________
From: software visualization
[mailto:softwarevisualization@gmail.com (softwarevisualization@gmail.com)]
Sent: 27 June 2008 16:48
To: nbusers@netbeans.org (nbusers@netbeans.org)
Subject: [nbusers] building wipes out directory
New to netbeans....
I have a directory (images) which contains .png files. I refer to
this directory in my program. Since it contains images I load at runtime and
no .java files, I put it under build-->classes--myProject so the path is
build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images directory.
I've tried telling NB not to do this through
properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has an obvious
solution I am overlooking.
Many thanks.
|
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.101 / Virus Database: 270.4.1/1522 - Release Date: 6/27/2008 8:27 AM
|
|
|
|
| Back to top |
|
 |
software visualization Posted via mailing list.
|
Posted: Fri Jun 27, 2008 6:48 pm Post subject: building wipes out directory |
|
|
Just to make this thread more useful to follow-on readers, here's what I learned from some documentation:
When you build the project, the bytecode file HelloWorldApp.class is generated. You can see where the new file is generated by opening the Files window and expanding the Hello World App/build/classes/helloworldapp node as shown in the following figure.
SO the compilation does go to the build directory... still have to understand why it does this and hopefully how I can stop it from wiping out my images directory...
On Fri, Jun 27, 2008 at 2:35 PM, software visualization <softwarevisualization@gmail.com (softwarevisualization@gmail.com)> wrote:
| Quote: | QUOTE The build directory structure is not on the run classpath at all.END_QUOTE
I think this means I understand so little, I don't even know what I don't understand. If the build directory with its .class files isn't where the result f a the build goes, then where does that result go and what is the build directory?
Obviously I'm just at sea here... time to buy a book on the subject... many thanks to everyone who replied.
sincerely.
On Fri, Jun 27, 2008 at 1:48 PM, Bayless Kirtley <bkirt@cox.net (bkirt@cox.net)> wrote:
| Quote: | Actually, I think Netbeans expects you to run from the jar file rather than the class files. The build directory structure is not on the run classpath at all. I keep images and other miscellaneous runtime stuff in a directory under the project tree, parallel with the dist directory. For simplicity, I just hard code the path to these within my source, eg. "../images/xxx".. It works well for me that way.
Bayless
| Quote: |
----- Original Message -----
From: software visualization (softwarevisualization@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Friday, June 27, 2008 11:46 AM
Subject: Re: [nbusers] building wipes out directory
OK so I am used to putting these kinds of non-compilable (i.e. non .java files) resources in the directory which contains the class files, since that is supposedly on the classpath and where java looks for things at runtime. So I looked to see where NB puts .class files (where they end up when the source is compiled) and that was the "build folder". I placed the images directory there for that reason.
To me "build" means, essentially "compile the project classes, resolving dependencies, and place them where it is you (NB) place them.. probably some sensible default "place" which ultimately is configurable in some way which I'll learn about later.....".
So I had no reason to believe that an "images" folder would "end up" anywhere useful if it and its contents existed in my sources. That, at least, is what happens if you put an image folder containing just images in your source directory using javac from the command line and some other IDEs.
So now that I've laid out my primitive interpretation - in gory detail - of what it means to "build" something what is it I need to get acquainted with so that my understanding and reality start to look like each other?
Many thanks.
On Fri, Jun 27, 2008 at 12:07 PM, Ian Carter <iccarter@gotadsl.co.uk (iccarter@gotadsl.co.uk)> wrote:
| Quote: | What you are telling NetBeans when you "clean and build" is to delete the
build area and re-create it by builing your classes.
So, yes, all files in that area will be deleted.
Ian
________________________________
From: software visualization
[mailto:softwarevisualization@gmail.com (softwarevisualization@gmail.com)]
Sent: 27 June 2008 16:48
To: nbusers@netbeans.org (nbusers@netbeans.org)
Subject: [nbusers] building wipes out directory
New to netbeans....
I have a directory (images) which contains .png files. I refer to
this directory in my program. Since it contains images I load at runtime and
no .java files, I put it under build-->classes--myProject so the path is
build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images directory.
I've tried telling NB not to do this through
properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has an obvious
solution I am overlooking.
Many thanks.
|
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.101 / Virus Database: 270.4.1/1522 - Release Date: 6/27/2008 8:27 AM
|
|
|
|
|
| Back to top |
|
 |
Marc Farrow Posted via mailing list.
|
Posted: Fri Jun 27, 2008 6:58 pm Post subject: building wipes out directory |
|
|
I think you are just confused in the difference between NB's build process and command-line java build processes.
NB uses Ant. The build process in NB is this.
1) Compiles the files into the "build" directory. (compile task)
2) Creates a distributable file in the "dist" directory. (dist task)
a) This file can be a jar, war, etc, etc.
When you run the Java class (or Jar) from within NB, the classpath that is used for the run-time is located in the project properties window. Check out the "Libararies" category. This will show you the different classpaths (compile, compile tests, run, run tests). NB takes care of the classpath for you when you run it through NB. So NB (by default) only knows aobut the libraries/projects/folders, etc that you have specified in this window. It will add this stuff to the libarary. However, you are accessing non-compilable stuff (which I will refer to as "images" throughout the rest of this post since you are directly referring to *.png files) from within Java. So you really need to think about where the "images" are going to be when you run it in a production environment. In that case you have the following options (some of which is repeat from previous posters).
PLEASE NOTE: I am making the assumption here that you are accessing these png files via Java code and not trying to use them on a web page or anything like that.
1) Place the "images" in a static location in which the development environment can read. Duplicate this set up in the production environment so that the code does not have to change (or use system/environment variables to control this location).
2) Place the "images" into a folder in develiopment environment and change your build.xml and create a target called "-post-compile" or "-pre-dist" and have this copy the "images" to where you want them in the "classes" folder. Therefore, when you build your project the files are copied where you want them.
3) Place the "images" into a folder under your "source" folders of your project. When the project is built, the java code and also the "images" should all be created in the "classes" folder which matches the same folder structure which in turn will be included in the dist file.
4) Place the "images" into a package under your "source" folder and access them via the "Resources" API built into Java. You can just use a Java API call to get the resource as stream (ClassLoader.getResourceAsStream()). If the "images" are going to be unique to this project and implementation, this seems like the best way to manage them. They are apart of the project and you do not have to worry about absolute or relative paths. Of course, this depends on your intended us of said objects.
HTH and GL
On Fri, Jun 27, 2008 at 2:35 PM, software visualization <softwarevisualization@gmail.com (softwarevisualization@gmail.com)> wrote:
| Quote: | QUOTE The build directory structure is not on the run classpath at all.END_QUOTE
I think this means I understand so little, I don't even know what I don't understand. If the build directory with its .class files isn't where the result f a the build goes, then where does that result go and what is the build directory?
Obviously I'm just at sea here... time to buy a book on the subject... many thanks to everyone who replied.
sincerely.
On Fri, Jun 27, 2008 at 1:48 PM, Bayless Kirtley <bkirt@cox.net (bkirt@cox.net)> wrote:
| Quote: | Actually, I think Netbeans expects you to run from the jar file rather than the class files. The build directory structure is not on the run classpath at all. I keep images and other miscellaneous runtime stuff in a directory under the project tree, parallel with the dist directory. For simplicity, I just hard code the path to these within my source, eg. "../images/xxx".. It works well for me that way.
Bayless
| Quote: |
----- Original Message -----
From: software visualization (softwarevisualization@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Friday, June 27, 2008 11:46 AM
Subject: Re: [nbusers] building wipes out directory
OK so I am used to putting these kinds of non-compilable (i.e. non .java files) resources in the directory which contains the class files, since that is supposedly on the classpath and where java looks for things at runtime. So I looked to see where NB puts .class files (where they end up when the source is compiled) and that was the "build folder". I placed the images directory there for that reason.
To me "build" means, essentially "compile the project classes, resolving dependencies, and place them where it is you (NB) place them.. probably some sensible default "place" which ultimately is configurable in some way which I'll learn about later.....".
So I had no reason to believe that an "images" folder would "end up" anywhere useful if it and its contents existed in my sources. That, at least, is what happens if you put an image folder containing just images in your source directory using javac from the command line and some other IDEs.
So now that I've laid out my primitive interpretation - in gory detail - of what it means to "build" something what is it I need to get acquainted with so that my understanding and reality start to look like each other?
Many thanks.
On Fri, Jun 27, 2008 at 12:07 PM, Ian Carter <iccarter@gotadsl.co.uk (iccarter@gotadsl.co.uk)> wrote:
| Quote: | What you are telling NetBeans when you "clean and build" is to delete the
build area and re-create it by builing your classes.
So, yes, all files in that area will be deleted.
Ian
________________________________
From: software visualization
[mailto:softwarevisualization@gmail.com (softwarevisualization@gmail.com)]
Sent: 27 June 2008 16:48
To: nbusers@netbeans.org (nbusers@netbeans.org)
Subject: [nbusers] building wipes out directory
New to netbeans....
I have a directory (images) which contains .png files. I refer to
this directory in my program. Since it contains images I load at runtime and
no .java files, I put it under build-->classes--myProject so the path is
build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images directory.
I've tried telling NB not to do this through
properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has an obvious
solution I am overlooking.
Many thanks.
|
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.101 / Virus Database: 270.4.1/1522 - Release Date: 6/27/2008 8:27 AM
|
|
|
|
|
| Back to top |
|
 |
software visualization Posted via mailing list.
|
Posted: Fri Jun 27, 2008 7:02 pm Post subject: building wipes out directory |
|
|
oh yeah that totally helps thanks .. I will check out the "libraries" category...saved me many hours of search and find... tnx....
On Fri, Jun 27, 2008 at 2:57 PM, Marc Farrow <marc.farrow@gmail.com (marc.farrow@gmail.com)> wrote:
| Quote: | I think you are just confused in the difference between NB's build process and command-line java build processes.
NB uses Ant. The build process in NB is this.
1) Compiles the files into the "build" directory. (compile task)
2) Creates a distributable file in the "dist" directory. (dist task)
a) This file can be a jar, war, etc, etc.
When you run the Java class (or Jar) from within NB, the classpath that is used for the run-time is located in the project properties window. Check out the "Libararies" category. This will show you the different classpaths (compile, compile tests, run, run tests). NB takes care of the classpath for you when you run it through NB. So NB (by default) only knows aobut the libraries/projects/folders, etc that you have specified in this window. It will add this stuff to the libarary. However, you are accessing non-compilable stuff (which I will refer to as "images" throughout the rest of this post since you are directly referring to *.png files) from within Java. So you really need to think about where the "images" are going to be when you run it in a production environment. In that case you have the following options (some of which is repeat from previous posters).
PLEASE NOTE: I am making the assumption here that you are accessing these png files via Java code and not trying to use them on a web page or anything like that.
1) Place the "images" in a static location in which the development environment can read. Duplicate this set up in the production environment so that the code does not have to change (or use system/environment variables to control this location).
2) Place the "images" into a folder in develiopment environment and change your build.xml and create a target called "-post-compile" or "-pre-dist" and have this copy the "images" to where you want them in the "classes" folder. Therefore, when you build your project the files are copied where you want them.
3) Place the "images" into a folder under your "source" folders of your project. When the project is built, the java code and also the "images" should all be created in the "classes" folder which matches the same folder structure which in turn will be included in the dist file.
4) Place the "images" into a package under your "source" folder and access them via the "Resources" API built into Java. You can just use a Java API call to get the resource as stream (ClassLoader.getResourceAsStream()). If the "images" are going to be unique to this project and implementation, this seems like the best way to manage them. They are apart of the project and you do not have to worry about absolute or relative paths. Of course, this depends on your intended us of said objects.
HTH and GL
On Fri, Jun 27, 2008 at 2:35 PM, software visualization <softwarevisualization@gmail.com (softwarevisualization@gmail.com)> wrote:
| Quote: | QUOTE The build directory structure is not on the run classpath at all.END_QUOTE
I think this means I understand so little, I don't even know what I don't understand. If the build directory with its .class files isn't where the result f a the build goes, then where does that result go and what is the build directory?
Obviously I'm just at sea here... time to buy a book on the subject... many thanks to everyone who replied.
sincerely.
On Fri, Jun 27, 2008 at 1:48 PM, Bayless Kirtley <bkirt@cox.net (bkirt@cox.net)> wrote:
| Quote: | Actually, I think Netbeans expects you to run from the jar file rather than the class files. The build directory structure is not on the run classpath at all. I keep images and other miscellaneous runtime stuff in a directory under the project tree, parallel with the dist directory. For simplicity, I just hard code the path to these within my source, eg. "../images/xxx".. It works well for me that way.
Bayless
| Quote: |
----- Original Message -----
From: software visualization (softwarevisualization@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Friday, June 27, 2008 11:46 AM
Subject: Re: [nbusers] building wipes out directory
OK so I am used to putting these kinds of non-compilable (i.e. non .java files) resources in the directory which contains the class files, since that is supposedly on the classpath and where java looks for things at runtime. So I looked to see where NB puts .class files (where they end up when the source is compiled) and that was the "build folder". I placed the images directory there for that reason.
To me "build" means, essentially "compile the project classes, resolving dependencies, and place them where it is you (NB) place them.. probably some sensible default "place" which ultimately is configurable in some way which I'll learn about later.....".
So I had no reason to believe that an "images" folder would "end up" anywhere useful if it and its contents existed in my sources. That, at least, is what happens if you put an image folder containing just images in your source directory using javac from the command line and some other IDEs.
So now that I've laid out my primitive interpretation - in gory detail - of what it means to "build" something what is it I need to get acquainted with so that my understanding and reality start to look like each other?
Many thanks.
On Fri, Jun 27, 2008 at 12:07 PM, Ian Carter <iccarter@gotadsl.co.uk (iccarter@gotadsl.co.uk)> wrote:
| Quote: | What you are telling NetBeans when you "clean and build" is to delete the
build area and re-create it by builing your classes.
So, yes, all files in that area will be deleted.
Ian
________________________________
From: software visualization
[mailto:softwarevisualization@gmail.com (softwarevisualization@gmail.com)]
Sent: 27 June 2008 16:48
To: nbusers@netbeans.org (nbusers@netbeans.org)
Subject: [nbusers] building wipes out directory
New to netbeans....
I have a directory (images) which contains .png files. I refer to
this directory in my program. Since it contains images I load at runtime and
no .java files, I put it under build-->classes--myProject so the path is
build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images directory.
I've tried telling NB not to do this through
properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has an obvious
solution I am overlooking.
Many thanks.
|
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.101 / Virus Database: 270.4.1/1522 - Release Date: 6/27/2008 8:27 AM
|
|
|
|
|
|
| Back to top |
|
 |
Marc Farrow Posted via mailing list.
|
Posted: Fri Jun 27, 2008 7:03 pm Post subject: building wipes out directory |
|
|
I think you are just confused in the difference between NB's build process and command-line java build processes.
NB uses Ant. The build process in NB is this.
1) Compiles the files into the "build" directory. (compile task)
2) Creates a distributable file in the "dist" directory. (dist task)
a) This file can be a jar, war, etc, etc.
The "clean" command deletes both the "dist" and "build" folders.
When you run the Java class (or Jar) from within NB, the classpath that is used for the run-time is located in the project properties window. Check out the "Libararies" category. This will show you the different classpaths (compile, compile tests, run, run tests). NB takes care of the classpath for you when you run it through NB. So NB (by default) only knows aobut the libraries/projects/folders, etc that you have specified in this window. It will add this stuff to the libarary. However, you are accessing non-compilable stuff (which I will refer to as "images" throughout the rest of this post since you are directly referring to *.png files) from within Java. So you really need to think about where the "images" are going to be when you run it in a production environment. In that case you have the following options (some of which is repeat from previous posters).
PLEASE NOTE: I am making the assumption here that you are accessing these png files via Java code and not trying to use them on a web page or anything like that.
1) Place the "images" in a static location in which the development environment can read. Duplicate this set up in the production environment so that the code does not have to change (or use system/environment variables to control this location).
2) Place the "images" into a folder in develiopment environment and change your build.xml and create a target called "-post-compile" or "-pre-dist" and have this copy the "images" to where you want them in the "classes" folder. Therefore, when you build your project the files are copied where you want them.
3) Place the "images" into a folder under your "source" folders of your project. When the project is built, the java code and also the "images" should all be created in the "classes" folder which matches the same folder structure which in turn will be included in the dist file.
4) Place the "images" into a package under your "source" folder and access them via the "Resources" API built into Java. You can just use a Java API call to get the resource as stream (ClassLoader.getResourceAsStream()). If the "images" are going to be unique to this project and implementation, this seems like the best way to manage them. They are apart of the project and you do not have to worry about absolute or relative paths. Of course, this depends on your intended us of said objects.
HTH and GL
On Fri, Jun 27, 2008 at 2:35 PM, software visualization <softwarevisualization@gmail.com (softwarevisualization@gmail.com)> wrote:
| Quote: | QUOTE The build directory structure is not on the run classpath at all.END_QUOTE
I think this means I understand so little, I don't even know what I don't understand. If the build directory with its .class files isn't where the result f a the build goes, then where does that result go and what is the build directory?
Obviously I'm just at sea here... time to buy a book on the subject... many thanks to everyone who replied.
sincerely.
On Fri, Jun 27, 2008 at 1:48 PM, Bayless Kirtley <bkirt@cox.net (bkirt@cox.net)> wrote:
| Quote: | Actually, I think Netbeans expects you to run from the jar file rather than the class files. The build directory structure is not on the run classpath at all. I keep images and other miscellaneous runtime stuff in a directory under the project tree, parallel with the dist directory. For simplicity, I just hard code the path to these within my source, eg. "../images/xxx".. It works well for me that way.
Bayless
| Quote: |
----- Original Message -----
From: software visualization (softwarevisualization@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Friday, June 27, 2008 11:46 AM
Subject: Re: [nbusers] building wipes out directory
OK so I am used to putting these kinds of non-compilable (i.e. non .java files) resources in the directory which contains the class files, since that is supposedly on the classpath and where java looks for things at runtime. So I looked to see where NB puts .class files (where they end up when the source is compiled) and that was the "build folder". I placed the images directory there for that reason.
To me "build" means, essentially "compile the project classes, resolving dependencies, and place them where it is you (NB) place them.. probably some sensible default "place" which ultimately is configurable in some way which I'll learn about later.....".
So I had no reason to believe that an "images" folder would "end up" anywhere useful if it and its contents existed in my sources. That, at least, is what happens if you put an image folder containing just images in your source directory using javac from the command line and some other IDEs.
So now that I've laid out my primitive interpretation - in gory detail - of what it means to "build" something what is it I need to get acquainted with so that my understanding and reality start to look like each other?
Many thanks.
On Fri, Jun 27, 2008 at 12:07 PM, Ian Carter <iccarter@gotadsl.co.uk (iccarter@gotadsl.co.uk)> wrote:
| Quote: | What you are telling NetBeans when you "clean and build" is to delete the
build area and re-create it by builing your classes.
So, yes, all files in that area will be deleted.
Ian
________________________________
From: software visualization
[mailto:softwarevisualization@gmail.com (softwarevisualization@gmail.com)]
Sent: 27 June 2008 16:48
To: nbusers@netbeans.org (nbusers@netbeans.org)
Subject: [nbusers] building wipes out directory
New to netbeans....
I have a directory (images) which contains .png files. I refer to
this directory in my program. Since it contains images I load at runtime and
no .java files, I put it under build-->classes--myProject so the path is
build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images directory.
I've tried telling NB not to do this through
properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has an obvious
solution I am overlooking.
Many thanks.
|
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.101 / Virus Database: 270.4.1/1522 - Release Date: 6/27/2008 8:27 AM
|
|
|
|
|
| Back to top |
|
 |
software visualization Posted via mailing list.
|
Posted: Fri Jun 27, 2008 7:12 pm Post subject: building wipes out directory |
|
|
Yeah I see that file build.xml ... this means I have to learn ANT... *laughs at self*
On Fri, Jun 27, 2008 at 3:01 PM, Marc Farrow <marc.farrow@gmail.com (marc.farrow@gmail.com)> wrote:
| Quote: | I think you are just confused in the difference between NB's build process and command-line java build processes.
NB uses Ant. The build process in NB is this.
1) Compiles the files into the "build" directory. (compile task)
2) Creates a distributable file in the "dist" directory. (dist task)
a) This file can be a jar, war, etc, etc.
The "clean" command deletes both the "dist" and "build" folders.
When you run the Java class (or Jar) from within NB, the classpath that is used for the run-time is located in the project properties window. Check out the "Libararies" category. This will show you the different classpaths (compile, compile tests, run, run tests). NB takes care of the classpath for you when you run it through NB. So NB (by default) only knows aobut the libraries/projects/folders, etc that you have specified in this window. It will add this stuff to the libarary. However, you are accessing non-compilable stuff (which I will refer to as "images" throughout the rest of this post since you are directly referring to *.png files) from within Java. So you really need to think about where the "images" are going to be when you run it in a production environment. In that case you have the following options (some of which is repeat from previous posters).
PLEASE NOTE: I am making the assumption here that you are accessing these png files via Java code and not trying to use them on a web page or anything like that.
1) Place the "images" in a static location in which the development environment can read. Duplicate this set up in the production environment so that the code does not have to change (or use system/environment variables to control this location).
2) Place the "images" into a folder in develiopment environment and change your build.xml and create a target called "-post-compile" or "-pre-dist" and have this copy the "images" to where you want them in the "classes" folder. Therefore, when you build your project the files are copied where you want them.
3) Place the "images" into a folder under your "source" folders of your project. When the project is built, the java code and also the "images" should all be created in the "classes" folder which matches the same folder structure which in turn will be included in the dist file.
4) Place the "images" into a package under your "source" folder and access them via the "Resources" API built into Java. You can just use a Java API call to get the resource as stream (ClassLoader.getResourceAsStream()). If the "images" are going to be unique to this project and implementation, this seems like the best way to manage them. They are apart of the project and you do not have to worry about absolute or relative paths. Of course, this depends on your intended us of said objects.
HTH and GL
On Fri, Jun 27, 2008 at 2:35 PM, software visualization <softwarevisualization@gmail.com (softwarevisualization@gmail.com)> wrote:
| Quote: | QUOTE The build directory structure is not on the run classpath at all.END_QUOTE
I think this means I understand so little, I don't even know what I don't understand. If the build directory with its .class files isn't where the result f a the build goes, then where does that result go and what is the build directory?
Obviously I'm just at sea here... time to buy a book on the subject... many thanks to everyone who replied.
sincerely.
On Fri, Jun 27, 2008 at 1:48 PM, Bayless Kirtley <bkirt@cox.net (bkirt@cox.net)> wrote:
| Quote: | Actually, I think Netbeans expects you to run from the jar file rather than the class files. The build directory structure is not on the run classpath at all. I keep images and other miscellaneous runtime stuff in a directory under the project tree, parallel with the dist directory. For simplicity, I just hard code the path to these within my source, eg. "../images/xxx".. It works well for me that way.
Bayless
| Quote: |
----- Original Message -----
From: software visualization (softwarevisualization@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Friday, June 27, 2008 11:46 AM
Subject: Re: [nbusers] building wipes out directory
OK so I am used to putting these kinds of non-compilable (i.e. non .java files) resources in the directory which contains the class files, since that is supposedly on the classpath and where java looks for things at runtime. So I looked to see where NB puts .class files (where they end up when the source is compiled) and that was the "build folder". I placed the images directory there for that reason.
To me "build" means, essentially "compile the project classes, resolving dependencies, and place them where it is you (NB) place them.. probably some sensible default "place" which ultimately is configurable in some way which I'll learn about later.....".
So I had no reason to believe that an "images" folder would "end up" anywhere useful if it and its contents existed in my sources. That, at least, is what happens if you put an image folder containing just images in your source directory using javac from the command line and some other IDEs.
So now that I've laid out my primitive interpretation - in gory detail - of what it means to "build" something what is it I need to get acquainted with so that my understanding and reality start to look like each other?
Many thanks.
On Fri, Jun 27, 2008 at 12:07 PM, Ian Carter <iccarter@gotadsl.co.uk (iccarter@gotadsl.co.uk)> wrote:
| Quote: | What you are telling NetBeans when you "clean and build" is to delete the
build area and re-create it by builing your classes.
So, yes, all files in that area will be deleted.
Ian
________________________________
From: software visualization
[mailto:softwarevisualization@gmail.com (softwarevisualization@gmail.com)]
Sent: 27 June 2008 16:48
To: nbusers@netbeans.org (nbusers@netbeans.org)
Subject: [nbusers] building wipes out directory
New to netbeans....
I have a directory (images) which contains .png files. I refer to
this directory in my program. Since it contains images I load at runtime and
no .java files, I put it under build-->classes--myProject so the path is
build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images directory.
I've tried telling NB not to do this through
properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has an obvious
solution I am overlooking.
Many thanks.
|
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.101 / Virus Database: 270.4.1/1522 - Release Date: 6/27/2008 8:27 AM
|
|
|
|
|
|
| Back to top |
|
 |
Johnny Kewl Posted via mailing list.
|
Posted: Fri Jun 27, 2008 11:12 pm Post subject: building wipes out directory |
|
|
Ha ha... just think of it like this...
The build folder is where NB puts stuff so it can debug it... it continually cleaned and built.
But ultimately it all ends up in the DIST folder, and the whole project is inside a JAR, WAR or whatever.
Which is just a ZIP.
When you stick your images under the source folder, they will end up in that JAR... and thats cool because they not floating around outside. You can load any resource from a Jar.
If you want to see this, make a little swing app, and use the property wizard to select an Icon...
It will make the code for reading the image and it will stick it in the Jar == Src folder...
Then just copy and paste, and study that a little....
You can base your data on a relative path... but it assumes that the working directory is set by the user, and the user would also have to drag your external files around, or zip them, and in java thats not needed because the Jar is already a zip.
... no you dont have to learn ant
Also something else thats a little strange for an ex VB guy... there is no function in Java to find out where you are... so in general, outside a Jar is not a good idea Its different but it works.
Microsoft hides "resources" at the end of the binary... Java hides nothing, the whole Jar is just a Zip.
Have fun...
| Quote: | ----- Original Message -----
From: software visualization (softwarevisualization@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Friday, June 27, 2008 9:11 PM
Subject: Re: [nbusers] building wipes out directory
Yeah I see that file build.xml ... this means I have to learn ANT... *laughs at self*
On Fri, Jun 27, 2008 at 3:01 PM, Marc Farrow <marc.farrow@gmail.com (marc.farrow@gmail.com)> wrote:
| Quote: | I think you are just confused in the difference between NB's build process and command-line java build processes.
NB uses Ant. The build process in NB is this.
1) Compiles the files into the "build" directory. (compile task)
2) Creates a distributable file in the "dist" directory. (dist task)
a) This file can be a jar, war, etc, etc.
The "clean" command deletes both the "dist" and "build" folders.
When you run the Java class (or Jar) from within NB, the classpath that is used for the run-time is located in the project properties window. Check out the "Libararies" category. This will show you the different classpaths (compile, compile tests, run, run tests). NB takes care of the classpath for you when you run it through NB. So NB (by default) only knows aobut the libraries/projects/folders, etc that you have specified in this window. It will add this stuff to the libarary. However, you are accessing non-compilable stuff (which I will refer to as "images" throughout the rest of this post since you are directly referring to *.png files) from within Java. So you really need to think about where the "images" are going to be when you run it in a production environment. In that case you have the following options (some of which is repeat from previous posters).
PLEASE NOTE: I am making the assumption here that you are accessing these png files via Java code and not trying to use them on a web page or anything like that.
1) Place the "images" in a static location in which the development environment can read. Duplicate this set up in the production environment so that the code does not have to change (or use system/environment variables to control this location).
2) Place the "images" into a folder in develiopment environment and change your build.xml and create a target called "-post-compile" or "-pre-dist" and have this copy the "images" to where you want them in the "classes" folder. Therefore, when you build your project the files are copied where you want them.
3) Place the "images" into a folder under your "source" folders of your project. When the project is built, the java code and also the "images" should all be created in the "classes" folder which matches the same folder structure which in turn will be included in the dist file.
4) Place the "images" into a package under your "source" folder and access them via the "Resources" API built into Java. You can just use a Java API call to get the resource as stream (ClassLoader.getResourceAsStream()). If the "images" are going to be unique to this project and implementation, this seems like the best way to manage them. They are apart of the project and you do not have to worry about absolute or relative paths. Of course, this depends on your intended us of said objects.
HTH and GL
On Fri, Jun 27, 2008 at 2:35 PM, software visualization <softwarevisualization@gmail.com (softwarevisualization@gmail.com)> wrote:
| Quote: | QUOTE The build directory structure is not on the run classpath at all.END_QUOTE
I think this means I understand so little, I don't even know what I don't understand. If the build directory with its .class files isn't where the result f a the build goes, then where does that result go and what is the build directory?
Obviously I'm just at sea here... time to buy a book on the subject... many thanks to everyone who replied.
sincerely.
On Fri, Jun 27, 2008 at 1:48 PM, Bayless Kirtley <bkirt@cox.net (bkirt@cox.net)> wrote:
| Quote: | Actually, I think Netbeans expects you to run from the jar file rather than the class files. The build directory structure is not on the run classpath at all. I keep images and other miscellaneous runtime stuff in a directory under the project tree, parallel with the dist directory. For simplicity, I just hard code the path to these within my source, eg. "../images/xxx".. It works well for me that way.
Bayless
| Quote: |
----- Original Message -----
From: software visualization (softwarevisualization@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Friday, June 27, 2008 11:46 AM
Subject: Re: [nbusers] building wipes out directory
OK so I am used to putting these kinds of non-compilable (i.e. non .java files) resources in the directory which contains the class files, since that is supposedly on the classpath and where java looks for things at runtime. So I looked to see where NB puts .class files (where they end up when the source is compiled) and that was the "build folder". I placed the images directory there for that reason.
To me "build" means, essentially "compile the project classes, resolving dependencies, and place them where it is you (NB) place them.. probably some sensible default "place" which ultimately is configurable in some way which I'll learn about later.....".
So I had no reason to believe that an "images" folder would "end up" anywhere useful if it and its contents existed in my sources. That, at least, is what happens if you put an image folder containing just images in your source directory using javac from the command line and some other IDEs.
So now that I've laid out my primitive interpretation - in gory detail - of what it means to "build" something what is it I need to get acquainted with so that my understanding and reality start to look like each other?
Many thanks.
On Fri, Jun 27, 2008 at 12:07 PM, Ian Carter <iccarter@gotadsl.co.uk (iccarter@gotadsl.co.uk)> wrote:
| Quote: | What you are telling NetBeans when you "clean and build" is to delete the
build area and re-create it by builing your classes.
So, yes, all files in that area will be deleted.
Ian
________________________________
From: software visualization
[mailto:softwarevisualization@gmail.com (softwarevisualization@gmail.com)]
Sent: 27 June 2008 16:48
To: nbusers@netbeans.org (nbusers@netbeans.org)
Subject: [nbusers] building wipes out directory
New to netbeans....
I have a directory (images) which contains .png files. I refer to
this directory in my program. Since it contains images I load at runtime and
no .java files, I put it under build-->classes--myProject so the path is
build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images directory.
I've tried telling NB not to do this through
properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has an obvious
solution I am overlooking.
Many thanks.
|
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.101 / Virus Database: 270.4.1/1522 - Release Date: 6/27/2008 8:27 AM
|
|
|
|
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------
HAPPY BIRTHDAY Nelson Mandella
---------------------------------------------------------------------------
|
|
|
| Back to top |
|
 |
software visualization Posted via mailing list.
|
Posted: Fri Jun 27, 2008 11:38 pm Post subject: building wipes out directory |
|
|
Well that rocks thanks for telling me that. I can continue to dodge the entire ANT bullet for yet another year... (my career is built on not learning as many things as possible (then redirecting that time to *really interesting stuff* that I can use in programming)
I assiduously use ClassLoader.getSystemResource for accessing "stuff" just because you can't rely on anything outside being anywhere outside the confines of the jar. I don't think even the concept of "users home directory" translates between platforms.
So that rocks.. thanks for the information!!!
On Fri, Jun 27, 2008 at 7:12 PM, Johnny Kewl <john@kewlstuff.co.za (john@kewlstuff.co.za)> wrote:
| Quote: | Ha ha... just think of it like this...
The build folder is where NB puts stuff so it can debug it... it continually cleaned and built.
But ultimately it all ends up in the DIST folder, and the whole project is inside a JAR, WAR or whatever.
Which is just a ZIP.
When you stick your images under the source folder, they will end up in that JAR... and thats cool because they not floating around outside. You can load any resource from a Jar.
If you want to see this, make a little swing app, and use the property wizard to select an Icon...
It will make the code for reading the image and it will stick it in the Jar == Src folder...
Then just copy and paste, and study that a little....
You can base your data on a relative path... but it assumes that the working directory is set by the user, and the user would also have to drag your external files around, or zip them, and in java thats not needed because the Jar is already a zip.
... no you dont have to learn ant
Also something else thats a little strange for an ex VB guy... there is no function in Java to find out where you are... so in general, outside a Jar is not a good idea Its different but it works.
Microsoft hides "resources" at the end of the binary... Java hides nothing, the whole Jar is just a Zip.
Have fun...
| Quote: | ----- Original Message -----
From: software visualization (softwarevisualization@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Friday, June 27, 2008 9:11 PM
Subject: Re: [nbusers] building wipes out directory
Yeah I see that file build.xml ... this means I have to learn ANT... *laughs at self*
On Fri, Jun 27, 2008 at 3:01 PM, Marc Farrow <marc.farrow@gmail.com (marc.farrow@gmail.com)> wrote:
| Quote: | I think you are just confused in the difference between NB's build process and command-line java build processes.
NB uses Ant. The build process in NB is this.
1) Compiles the files into the "build" directory. (compile task)
2) Creates a distributable file in the "dist" directory. (dist task)
a) This file can be a jar, war, etc, etc.
The "clean" command deletes both the "dist" and "build" folders.
When you run the Java class (or Jar) from within NB, the classpath that is used for the run-time is located in the project properties window. Check out the "Libararies" category. This will show you the different classpaths (compile, compile tests, run, run tests). NB takes care of the classpath for you when you run it through NB. So NB (by default) only knows aobut the libraries/projects/folders, etc that you have specified in this window. It will add this stuff to the libarary. However, you are accessing non-compilable stuff (which I will refer to as "images" throughout the rest of this post since you are directly referring to *.png files) from within Java. So you really need to think about where the "images" are going to be when you run it in a production environment. In that case you have the following options (some of which is repeat from previous posters).
PLEASE NOTE: I am making the assumption here that you are accessing these png files via Java code and not trying to use them on a web page or anything like that.
1) Place the "images" in a static location in which the development environment can read. Duplicate this set up in the production environment so that the code does not have to change (or use system/environment variables to control this location).
2) Place the "images" into a folder in develiopment environment and change your build.xml and create a target called "-post-compile" or "-pre-dist" and have this copy the "images" to where you want them in the "classes" folder. Therefore, when you build your project the files are copied where you want them.
3) Place the "images" into a folder under your "source" folders of your project. When the project is built, the java code and also the "images" should all be created in the "classes" folder which matches the same folder structure which in turn will be included in the dist file.
4) Place the "images" into a package under your "source" folder and access them via the "Resources" API built into Java. You can just use a Java API call to get the resource as stream (ClassLoader.getResourceAsStream()). If the "images" are going to be unique to this project and implementation, this seems like the best way to manage them. They are apart of the project and you do not have to worry about absolute or relative paths. Of course, this depends on your intended us of said objects.
HTH and GL
On Fri, Jun 27, 2008 at 2:35 PM, software visualization <softwarevisualization@gmail.com (softwarevisualization@gmail.com)> wrote:
| Quote: | QUOTE The build directory structure is not on the run classpath at all.END_QUOTE
I think this means I understand so little, I don't even know what I don't understand. If the build directory with its .class files isn't where the result f a the build goes, then where does that result go and what is the build directory?
Obviously I'm just at sea here... time to buy a book on the subject... many thanks to everyone who replied.
sincerely.
On Fri, Jun 27, 2008 at 1:48 PM, Bayless Kirtley <bkirt@cox.net (bkirt@cox.net)> wrote:
| Quote: | Actually, I think Netbeans expects you to run from the jar file rather than the class files. The build directory structure is not on the run classpath at all. I keep images and other miscellaneous runtime stuff in a directory under the project tree, parallel with the dist directory. For simplicity, I just hard code the path to these within my source, eg. "../images/xxx".. It works well for me that way.
Bayless
| Quote: |
----- Original Message -----
From: software visualization (softwarevisualization@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Friday, June 27, 2008 11:46 AM
Subject: Re: [nbusers] building wipes out directory
OK so I am used to putting these kinds of non-compilable (i.e. non .java files) resources in the directory which contains the class files, since that is supposedly on the classpath and where java looks for things at runtime. So I looked to see where NB puts .class files (where they end up when the source is compiled) and that was the "build folder". I placed the images directory there for that reason.
To me "build" means, essentially "compile the project classes, resolving dependencies, and place them where it is you (NB) place them.. probably some sensible default "place" which ultimately is configurable in some way which I'll learn about later.....".
So I had no reason to believe that an "images" folder would "end up" anywhere useful if it and its contents existed in my sources. That, at least, is what happens if you put an image folder containing just images in your source directory using javac from the command line and some other IDEs.
So now that I've laid out my primitive interpretation - in gory detail - of what it means to "build" something what is it I need to get acquainted with so that my understanding and reality start to look like each other?
Many thanks.
On Fri, Jun 27, 2008 at 12:07 PM, Ian Carter <iccarter@gotadsl.co.uk (iccarter@gotadsl.co.uk)> wrote:
| Quote: | What you are telling NetBeans when you "clean and build" is to delete the
build area and re-create it by builing your classes.
So, yes, all files in that area will be deleted.
Ian
________________________________
From: software visualization
[mailto:softwarevisualization@gmail.com (softwarevisualization@gmail.com)]
Sent: 27 June 2008 16:48
To: nbusers@netbeans.org (nbusers@netbeans.org)
Subject: [nbusers] building wipes out directory
New to netbeans....
I have a directory (images) which contains .png files. I refer to
this directory in my program. Since it contains images I load at runtime and
no .java files, I put it under build-->classes--myProject so the path is
build-->mkclasses-->myProject-->images.
When I clean and build, NB wipes out the images directory.
I've tried telling NB not to do this through
properties-->libraries-->compile-->add/jar/folder
properties-->libraries-->run-->add/jar/folder
and adding the images directory.
But this doesn't work. MB still wipes the folder out.
Like I said, I'm new to NB so i am hoping that this has an obvious
solution I am overlooking.
Many thanks.
|
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.101 / Virus Database: 270.4.1/1522 - Release Date: 6/27/2008 8:27 AM
|
|
|
|
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------
HAPPY BIRTHDAY Nelson Mandella
---------------------------------------------------------------------------
|
|
|
|
| Back to top |
|
 |
Johnny Kewl Posted via mailing list.
|
Posted: Sat Jun 28, 2008 7:19 am Post subject: building wipes out directory |
|
|
| Quote: | ----- Original Message -----
From: software visualization (softwarevisualization@gmail.com)
To: nbusers@netbeans.org (nbusers@netbeans.org)
Sent: Saturday, June 28, 2008 1:38 AM
Subject: Re: [nbusers] building wipes out directory
Well that rocks thanks for telling me that. I can continue to dodge the entire ANT bullet for yet another year... (my career is built on not learning as many things as possible (then redirecting that time to *really interesting stuff* that I can use in programming)
I assiduously use ClassLoader.getSystemResource for accessing "stuff" just because you can't rely on anything outside being anywhere outside the confines of the jar. I don't think even the concept of "users home directory" translates between platforms.
--------------
| Quote: | "users home directory" does work.... typically in a property file, in the src == jar is where you put the default values... the reason is you cant write back to the Jar, and even if you could, the next version of your application, would then reset user preferences.
So when the use sets their prefered colors and whatever else, you would typically write to the users folder.
BUT... in java you dont use say c:/documents and settings/user.... ie you dont get it yourself.
Use System.getProperty("user.home").... and use System.getProperty("file.separator") etc to setup your "user" locations.
That does port across systems.
You want to use that "user" folder because on a system with tight security, its one of the few places the user has access to.
On MS one thinks of "program" folders, but on linux its very much /user... and thats typically what you want to emulate.
Java.exe is the real program... the rest is really just ZIP's...
NB is there so we dont have to use ant... just let NB do its thing.
In general, if it start becoming too much work and too complex... theres an easier way
There are exceptions to the rule, like some obfusication tools, need messing with NB's ant, but in general, NB plugins are there so all that can be avoided.
Dont worry about ant.. when you get into IDE independent opensource projects, like building Tomcat yourself... you'll have to learn a little ant, and then you'll wish that the thing was just an NB project In a way, thats all NB really is, the frontend to ant
You right, in the Java world there seems to be two types of programmers... ones that keep it dead simple, and ones that make it hellish complex.
Have fun...
|
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|