I'd like to be able to open pdf files in a NetBeans project like this for a help menu but I don't see a way to add the pdf files to the project in a way that they will become part of the distribution. The application needs to be able to find the pdf files. I thought there might be an option to add the files to the project resources but this doesn't seem to be an option.
If you have a resource folder in your project then just copy it in there and then clean and build
or right-click on the folder and create a package
folder called "documents". Put your pdf in there and clean-and-build.
Related
I'm building a Java Swing Application. This project requires a jar file called JCalender. I've added this to Libraries folder and everything works fine on my computer in NetBeans. But when i open the same project in my friends NetBeans, it doesn't recognizes this library. I've to manually select the file placed inside the projects dist/lib folder. How to avoid this? please help!
But when i open the same project in my friends NetBeans, it doesn't
recognizes this library. I've to manually select the file placed
inside the projects dist/lib folder. How to avoid this?
You can't avoid this because it's not a problem actually. To compile and run a project you need to have access to the external libraries involved in the development, so if you open your NetBeans project in a different computer than yours you will definitely need to resolve the reference to the external libraries. There's no way for the IDE to do it automatically as far as I know.
Can't i give the relative path to the lib folder for that specific
library somewhere in project properties?
You could just give it a try. IMHO if the real goal is to share a project with other developers then I'd change the strategy. I'd create a Library (Tools -> Libraries) and tell my mates to create the very same library including the JCalendar JAR files in the library's classpath. I'd include this library in the project properties and finally I'd use a versioning tool like Git or SVN to share the project.
By doing this your mates still need a copy of the JAR file wrapped in a NetBeans Library, but the project properties won't point to a fixed/relative path looking for a JAR file but wil include a reference to a given Library. The Library itself will resolve the dependency to the JAR file. If you take a look to the project.properties file you'll see something like this:
javac.classpath=\
${file.reference.jcalendar-1.4.jar}
But if you as I've suggested then you'll see something like this:
javac.classpath=\
${libs.JCalendar.classpath}
Here libs.JCalendar.classpath will resolve the dependency so your mates can have the actual JAR file located in whatever folder they like and the project should compile just fine.
Another option is using Maven to manage the projects dependencies but honestly I'm not a Maven expert so I can't help you in this path.
You need to do a "clean and build" and your jar will be in the dist folder. It will include the external jars
You can read more about it here
I think your problem is due to you are providing absolute path of jar file.
while choosing jar on write side of filechooser there is option of
Relative path and Absolute path there you should click on Absolute path.
i am new to java , but anyway , i have faced the same problem and found a solution for my project
If you are in Netbeans , its would be very easy for you
Let you project name is ABC and all your dependent jar file is under the
the folder MyResourceCollection
now we need to permanently import all jars under this folder ,
So from Netbeans ,
right click on your project name
go to properties
go to library
in the library page , check the "libraries folder" label
you can find a browse button at the right side of the label
click browse and select the MyResourceCollection folder
a new window will come , just press Next-->Next--->Finish
all is done , now check yourself by moving the folder into different location
As you might notice, I'm quite new to netbeans and programming in general.
I've been working on a small project (homework) and now I need the .java files from one of the packages. When I build the project, i get a .jar archive with all the classes. When I compile the package I need, I get a .jar archive of the .class files of this package (in the "build" folder of the project). However, I need a zip archive of the .java files of this package. I'm a little embarassed to ask, but where do I get these from?
Thanks,
Zhao Nan
From the Projects window (Window-->Projects) or Ctri-1
Navigate to the .java file you want, and right-click on it, and select Properties. The path to the file is shown under All Files.
To see the path to the project right-click on the name of the project (in the Projects window), select Properties, and the project folder is shown under Sources-->Project Folder
If your are on windows, usually if you let netbeans create all by it self it creates a directory called
NetbeansProjects
Under "documents"
There will be a folder list of all your projects. Under the project name that interest you, go in the "src" folder. All your java files should be there.
On Ubuntu 16.04 using NetBeans IDE 8.2, a folder called NetBeansProjects was created in my root directory, parallel to the netbeans-8.2 directory. I'm guessing that this was suggested at installation time and can be configured differently.
Im wondering how do I export a java project to .jar at the same time with a folder that contain all the source files, so I dont mix the class files and the .java files together.
You can achieve this by Right clicking the Selected Project you want to be exported Export --> Jar File and check the following options.
and then click finish.
I read this article which shows how to import/export projects in Eclipse (although it seems a little outdated and I'm using 3.7 Indigo).
To export a project, you go to File >> Export and it creates some kind of "project archive" file on the local file system. You could then email it to someone else, who could then import the archive as a new project or into an existing project.
But what if you don't have an "archive" file to begin with?!? What if you just have the project files and directories but without all the Eclipse-metatdata (.project file, etc.)? Is there anyway to tell Eclipse to look at, say:
/home/myuser/some/path/to/project/root/
src/main/java
SomeObject.java
build.xml
...and get it to read that as a new Java project?
Try the steps below:
Create a Java Project in Eclipse as below:
Load the project contents from your file system as below:
Hope this works for you.
.project and .classpath files are the base of the project structure. Without a .project file Eclipse won't recognize your project. The .classpath is important too but that one changes between environments. Should you use the files from another environment you'll have to reconfigure some settings.
Rather than emailing code, I suggest you use a Version Control system and, also, some Eclipse plugins. SVN + Subclipse for example.
If you trully want to send the project to another person just send him the project's folder and import it as an existing project by doing right click on the project explorer and selecting Import > Existing Project into workspace.
Background
I'm using an Eclipse 4.2 (Juno) release to build a plugin for a Java application. The source code and classes for my plugin all reside within the project workspace. The application jar and its source code are, for various reasons maintained outside of the eclipse workspace and the application jar is produced by another build mechanism.
This isn't a problem as I have referenced the application jar file in my project using drag and drop and the 'Link to files' option specifying it 'Create link locations relative to: MYDEV', where MYDEV is a Linked Resource Variable I have created for each Eclipse installation. This lets me use the same eclipse project on multiple machines where the path to the application jar varies, but is always the same relative to MYDEV.
However, I cannot find a way to associate the application source code with this jar unless I use an absolute path. I only want access to the application source for debugging purposes.
Question
In Eclipse, how do I attach java source to a referenced jar in a way that allows a project to be used on multiple installations where the referenced source code has been relocated?
If the source is outside the proyect, then there's no way to access it without an absolute path.
The best solution is using a symlink inside the eclipse project directory to the actual source folder; eclipse won't notice the source is outside the project directory and everything will work fine, without having to relocate the source.
This is the only way I was able to do what you are suggesting (do not know if there are better ways).
Package a JAR file that contains the source code of the JAR file. Place it inside your project in a folder (you do not need to add it to your class path)
In the eclipse project right click on the JAR file and go to "properties" and then to "Java Source Attachment" From there select "Workspace" button and pick the jar file with the source code we added from the above step.
So the source attachment path will always be relative to the project. That way if you share the project via SVN, GIT or whatever, the source will always be available and it'll work if the user is running eclipse on Windows or Linux.
I've had a similar problem to you where absolute paths were a problem for people using different OS and not even using mapped drives via Samba helped that much.
Hope this helps.
The way I have solved this problem is to use a use defined library in eclipse. Here the steps that you can use to solver this problem.
Create a simple project in eclipse in the directory that contains the jars and the source code files.
Define a java user library add the jars to the user library and for each jar in the library specify the location of the source. If the source files are in a project that is in the workspace then the path will be relative to the workspace folder.
Export the user library as an .xml file
When another use wants to setup an eclipse workspace with the same setting as yours they will do two things.
Import the project that contains the jars and the sources into their workspace.
Import the user library into their workpsace.