spring framework download - java

So i downloaded Spring Jars from this link and I am trying to unzip the file, it keeps on complaining that some of the total path and file must not exceed 260 chars and it breaks from unzipping. How to download the jars and include them in my eclipse installation for working on my web projects, although this may seem trivial for some people it is very annoying to get around as i am new this kind of stuff. Really appreciate your help.
Thanks,
SS

Did you just unzip the zip file or the jar files? Just unzip the zip file, copy the jars in a lib folder in your project and add the jars to the buildpath of your project (Right click on the project -> Properties -> Java Build path -> Libraries -> Add jars).
And don't use the unzip functionality included in Windows, use an external program like 7zip. Then that error shouldn't occur.

You shouldn't need to unzip or unjar JAR files to use them in Eclipse. In fact, I'd recommend NOT doing this ... especially on Windows ... because it is liable to increase the amount of disk I/O.
But if you do want / need to do this, the jar command that is part of a Java JDK installation will be able to cope with them.

What you got was the correct ZIP . Now try to unzip it in something like c:\Spring instead of a nested folder like C:\Users\abcuser\Downloads\Spring\Spring Framework Notice the size difference between file paths.
To add jars to your eclipse project -
Right click project
Click "Build path" -> Configure Build Path... -> Libraries Tab
Click add external jar and select your jar

Related

How to open a Project in NetBeans

Hi guys I just clean and build my project in Netbeans, copy the folder of my project, put it in a ZIP archive and send it to myself. Now I don't know how to deploy the project, I tried just to copy the classes and run it, but it give me so many error, even if I try to recreate the structure of the packages with the same name it doesn't work. I tried to find information on the internet but is not very clear.
When I click on Clean and Build.
NeatBeans create a folder with the name of the project and inside> build,dist,nbproject,src,web,build
When you clean and build under Netbeans, you should find all you need under the dist folder:
if you a creating a web application you should find a .war file - that is the file to deploy: just copy it to the webapps folder for Tomcat
if you are creating a standalone application or a library, you should find the .jar
Above assume you do not use maven for the project. If you did you would not have a dist folder, but the standard maven target one.
I don't really know what are the errors you get. However check these few things out and see if it works for you:
check if you are importing from an external Library, if so, make sure that you have those libraries within your project.
If you are creating a new project and just copy pasting the classes, then make sure packages are correct and not from the other project you had.
it is pretty simple to open a project in net beans:
after creating your project and building it, zip the whole project folder.
once you unzipped it, use "CTRL+Shift+O" or the third option in netbeans>file to open a project.
a filechooser should open and you can select the project you want to open.
this is pretty much the whole thing you need to do.
you can also find the .war in webapps folder, .jar in dist folder too.
your question is really unclear. We dont know what is your project exactly nor your errors.
Please let me know the exact errors. so that I can help you with better.
I don't understand exactly what is the error your facing but I think that if you use the export and import project features of NetBeans maybe you wouldn't have that error in the first place:
To export project:
go to File -> Export Project -> To ZIP... -> Specify the zip destination directory.
To import project:
go to File -> Import Project -> From ZIP... -> And browse your file system to find the zip you previously created.

Android external Jar

I have some api with java and I need it in my android app.
When I am using it with including all packages and classes it works fine. Now I create JAR file from my java project using export. Now when I add the jar to my android app as a external jar my all errors are disappeared but when I run my app I got an error
java.lang.NoClassDefFoundError.
I have seen that kind of errors early in my apps and it was the problem of Jar. How can I generate JAR file to avoid this situation?
You have probably built that jar file with jdk 1.7. Classes compiled with jdk 1.7 are not included in apk file. Try to change java compiler to 1.6 before you export jar. In eclipse go to Window -> Preferences -> Java -> Compiler.
copy the jar file in the libs folder of your android project.
After that you may want to clean your project and rebuild it. You can even clear manually the bin dir content.
You have to add your jar file to your project's buildpath.
To make sure it's exported in your APK, you also have to check it under the Order and Export tab, in the build path preferences of your project.
A better approach might be the following:
remove the current exported jar from your project
select the project you want to import, right click -> properties -> android -> check 'mark as library'
right click your current project -> properties -> android -> locate the 'add' button in the bottom. Click it and select the library project.
Using this approach any changes in the library project will be reflected in your current project (at least after doing a clean projects).
I have done it !!! Thanks everybody.
So the solution is :
1. change java compiler to 1.6 before you export jar (As #Lecho mentioned)
2. Move the Jar file to lib folder
So it works !!! thanks everybody

How do I get eclipse to compile and copy only .java files during build?

I have a dynamic web project in eclipse (although I'm not using it as a web project. I would like to convert it to a java project if possible) and there are java files all over the place. There are also a lot of other files like images etc (which I don't want to remove because the project is linked to my SVN repo so if i do an update then everything will come back).
Now when i build my project eclipse copies all the files instead of compiling and copying the .java files only and this takes a lot of time because there are some 2GB worth of files.
I tried to include only .java files in the source by going to properties of my project -> Java Build Path -> source tab -> includes -> I added "*.java" to the textbox. However, no file got copied to my output folder after that.
how do i go about this? Deleting the images etc from my project is not a solution here.
Add **/*.java/ in the includes.

Netbeans not building the lib folder in the dist folder

I am trying to clean and build a jar but for some reason when I do a Run-> Clean and Build Main Project, I don't get a lib folder in the dist folder. This is causing a missing classes error when I run my jar file via cmd. How do I configure it to have the lib folder in my dist folder during my build? Thank you.
Edit:
Also, when I hit Run->Clean and Build Main Project, the output says the following:
2 warnings compile: Created dir: C:\Documents and
Settings\me\Desktop\ProjectX\ProjectX\dist C:\Documents and
Settings\me\Desktop\ProjectX\ProjectX\dist\ProjectX.jar is a directory
or can't be read. Not copying the libraries. Not copying the
libraries. Building jar: C:\Documents and
Settings\me\Desktop\ProjectX\ProjectX\dist\ProjectX.jar To run this
application from the command line without Ant, try: java -jar
"C:\Documents and
Settings\me\Desktop\ProjectX\ProjectX\dist\ProjectX.jar" jar: BUILD
SUCCESSFUL (total time: 3 seconds)
Why is it not copying the libraries during the build?
According to this forum.netbeans.org (cached copy as forums.netbeans.org is not accessible atm) article this could be caused by ProjectX.jar being added to the required JARs for some mysterious reason... Could be worth checking
EDIT: cached copy seems to have disappeared, the original thread can be found here.
EDIT again: as both the original and the cached copy have disappeared, head over to the wayback machine to read the article. That being said, anno 2018+ one should probably consider using a more modern / widespread project format like Maven, which is also well supported by Netbeans and offers a much more flexible libraries management approach.
In my case I went to Libraries->Properties. The "lib" folder was added as a library. remove it or remove them (several folders as libraries) and do clean and build.
Hope help you.
The url provided by #fvu die.
However I also have that problem and fixed it.
Exit Netbean
Delete your-project-name/nbproject/private
Open Netbean
Clean and build
In my case, I solved the same problem as follows :
1) Go to Project > Libraries > Properties > Libraries > Compile
2) Select missing libraries beginning 'Missing library :' and remove them
3) Clean and build
Cheers.
The problem is that you add the folder where are you libraries, you need to actually add the libraries and not the folder where they are.
1) Go to Project > Libraries > Properties > Libraries > Compile
delete the folder you add in these case C:\Documents and Settings\me\Desktop\ProjectX\ProjectX\dist
Select add JAR/Folder and these time open the folder and add all the libraries inside, Netbeans will allow you to select it all.
Now you suppose to be good.
There is a setting in Net Beans. Right click on Net Beans project you have created.
Click on Build->Packaging. You will get 03 options on the right pane
Compress JAR File
Build JAR after Compiling
Copy Dependent Libraries
Select the 03rd one and then build. You can see the /lib folder under /dist

Add resources into a jar upon building

I want to add DLL's, images, textfiles etc to my project as resources so when I export it, the jar contains the resources so they can be used. I am using eclipse.
Problem is I have no idea how to add it. I've tried adding DLLs/pics to the src folder in the project, but when I export the jar, it is not located there
I've looked at How to make a JAR file that includes DLL files? but it only explains how to extract it, not how to add it to the project and build.
EDIT: I am using an applet to open the jar by the way, sorry for missing it!
Cheers
How are you opening the file in java?
Class.getResourceAsStream(name)?
If you are packaging the code in a jar, then you need to use that command. (as opposed to new File(name), which will get the file in the same directory as your jar)
If the file is not physically in your jar, you can check by changing .jar to .zip and extracting it, then check out this doc http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javac.html
Usually in an eclipse project, the src folder is the wrong place to put non-sourcecode-content.
You should try moving to maven as your build system, as it is highly customizable and provides you with folders inside your project for exactly that purpose. (src/main/resources)

Categories

Resources