I have a NetBeans project that uses the GSON library. I've tried including the GSON.jar file without requiring future users to separately download it. However it doesn't seem to work. The project looks for the file from the relative path of my computer so the file isn't found on another user's computer. Is there a way to include GSON.jar and "Export to Zip" and keep the reference in the project itself? I'm lost!
Thank you
Exporting a Project to ZIP zips up the project folder only, and not anything outside of the folder, including dependencies. If you include the GSON.jar file in the project folder, then the JAR file will be included in the .ZIP file. It's a good practice anyway since NetBeans will use a relative classpath and thus if you move the project itself NetBeans won't give you an error message when loading the project.
Related
i have a project in eclipse that i work with SVN.
i need to upload a jar file to "referenced libraries" yet all i managed to do is uploading it to the main directory.
for some reason the file was uploaded to the main server directory instead of to referenced libraries which there it stayed local. i built the file path correctly i think. in the first place the JAR file was only on the referenced libraries.
how can i fix it?
thx
Try using TortoiseSVN. It will show you where you placed the jar and you can make adjustments accordingly.
I usually put the .jar that need to be referenced libraries in a lib directory under the project main directory. This way, when I checkin the project into SVN, the lib directory gets there as well.
My environment:
Netbean 6.9.1
Glassfish 3.0.1
Windows 7
Goal:
When my coworkers opens the Netbean Project, the library is already referenced without them manually create library, adding jars into it and reference it.
Detail:
I created Netbean project and the project has reference to few jar files in the folder.
Currently whoever opens the project for the first time, they have to manually create library and refer it to the project.
My project location:
C:\Users\masatosan\Desktop\myProject\myApp
My library location:
C:\Users\masatosan\Desktop\myProject\lib\myLib
The myLib folder contains:
some1.jar
some2.jar
some3.jar
I can achieve my goal if I create reference to individual jar file by defining to project.properties file like below: (creating reference to sqljdbc4.jar)
file.reference.sqljdbc4.jar=../lib/sqljdbc4.jar
javac.classpath=\
${libs.restlib_gfv3ee6.classpath}:\
${file.reference.sqljdbc4.jar}:
But my case is different since I have 3 jars in the myLib folder and wanting to reference them all.
Is it possible to reference all jars in myLib folder?
Please let me know if you need more clarification.
I'm sorry, but it doesn't work that way. When you create a project, you have to add the jar files individually.
However, if you put your lib folder under your project, netbeans will refer to them via relative paths. Then when you share the project (lib directory included), netbeans will be able to automatically find the jar files when the next person uses the project. That way you only have to add jar files once.
Short of using a dependency management tool like maven (which Netbeans has good support for), this is really the best solution. It uses a bit more disk space (obviously), but that's never been a huge issue for me.
I figured how so let me share.
Tool --> Library then library window pop up.
Create library called "MyLib" which contains multiple jars.
Add "MyLib" to your project. This change will be written to project.properties file under nbproject folder.
project.properties file indicates the classpath of lib reference you just added.
It should look like something below
javac.classpath=\
${libs.Excella.classpath}:\
${libs.MyLib.classpath}
Now someone else opens the project from different machine and she just needs to do step#1 and #2, which is to create library with same library name i.e. "MyLib"
I think this is what Bill was saying originally but thought it would be helpful to give step by step instructions since I finally figured .... after long time :D
I'm working with Maven project in Eclipse (with help of m2e plugin). When I pack my project into jar-file (mvn install), all files from "resources" are located in the root of jar.
Therefore, in my program I should use only bare file names:
File file = new File("foo.txt");
But when I build and run my project by Eclipse, I would have to use the relative path to the file:
File file = new File("src/main/resources/foo.txt");
What should I do to solve this problem?
To access your program's resources, don't use File, FileInputStream and similar classes.
They will not work for anything inside a jar file.
Instead, use Foo.class.getResource(...) or .getResourceAsStream() to access your resources. (Read the documentation before doing so.)
I'm not sure if a program started from eclipse can access these - please try and report back!
Your package configuration in Eclipse is wrong, cause it sees src/main/resources as a package instead of a source folder.
The configuration in Eclipse must look like this:
i have successfully configured sphinx4 with eclipse.
for that these steps i have used.
copy my java and config files to SRC folder
all the necessary jar files (in the lib). the lib folder added to the root of the project
build those jar files (jsapi files too)
change the configuration file and give the proper path
test the java file
but in Netbeans i really dont understand how to do the proper steps. can someone help me. the jar files should be added to "Libraries" rite.
then after adding them how to build them.
in the netbeans it dont show a SRC folder. so all the java files and configuration files should go to Source Packages folder rite.
can someone help me with this. please
If you have sphinx4-1.0beta6 then you can just open the folder up as a netbeans project. Open netbeans, click open project, then navigate to the sphinx folder and open it. It is already a netbeans project file type as of this version. I assume this will work in later versions also. I have no clue why sphinx doesn't say this on their website.
Sphinx4 is a Java library available in OSS repository, so you can use it as any library.
If your project uses maven/gradle, add repository in your project configuration, then add dependency on two packages - sphinx4 core and sphinx4-data. The former is the main library, the latter is required if you want to recognize US English. Then just start writing the code.
If you want to rely on jar files, just download sphinx4-core and sphinx4-data files from the repository and add them as dependency to the project, then start writing code.
If you want to modify or develop sphinx4 itself, install Gradle support in your IDE, then import latest sphinx4 sources as a Gradle project.
For more details and links see the tutorial
http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4
click on Add JAR/Folder
select jar file you want to add
I have configured my Eclipse to have a C:\Eclipse\external_libs directory where I place all my external libraries. In my case , my external libs are WATIJ, XMLUNIT, and XOM . Adding the external libs to the project is no problem... there is no question about that.
I also place my JDK at C:\Eclipse\Javasoft .
What I am wondering IS : is there a better location to place external libs? It's important to note that I like being able to pack my Eclipse directory into a zip file and move it and open it on another computer in a portable fashion.
It's normally done on a per app/project basis. For java webapps you normally have your external libs in WEB-INF/lib. However, if you share the libraries across projects AND you need to zip your eclipse directory, what you're doing now is probably the best solution imo.
In linux you could add them to something like /usr/lib/share and include that in your classpath (but you couldn't zip it all up), but not sure if that sort of directory exists in windows.
If you do place all your library in an external folder, please use "linked resources" to avoid putting any fixed path in your .classpath file.
You can then reference that external directory from within your project, with a linked folder.