Error while keeping .jar file in buildpath of project on 2 laptops - eclipse

I am using 2 laptops with the eclipse workspace synced through OneDrive.
I am working on a program which uses JDBC, with SQL. When I add the Connector/J.jar file to the build path from one PC, it shows an error in the other PC, and doesn't run at all. Is there any option to solve it such that no errors will be shown on any of the 2 PCs??
I want both my PCs to have their drives as clean as possible, so is there any way that I can have no errors without putting both the .jar files in a directory like C:\mysql-connector-java-8.0.23.jar??
P.S. I do not know much about build paths, so please explain in a simple language.

Yes, put the jars into the project itself so that the paths will be relative to the project.

Related

How to change the path of a jar file imported to a Netbeans project?

i imported a jfeonix jar file into my Netbeans project while it was in my pen drive. And it worked fine while the pen drive was still plugged on.
When i removed my pen, i cannot build my project and it says that
**Could not find resource file **
Then i tried copying the jar file to my desktop and then importing it again to the libraries of my project.. It would still give the same error, and the fact i fine surprising is that it still gives the same path as it was inside my pen drive even after i imported the jar file again from the Desktop..
So i was thinking what if i can changed the path to refer the jar file manually from inside the project...
has anyone faced this problem before?
Hope someone can help me with this..
Thanks in advance
i found the answer while doing a lot of things to my project..
apparently it seems that even if we delete the jar file from the library, it somehow is still there. and that's why it gives the same path even if we import the jar file again from a different place.
here's the answer i found, just in case someone faced this
Go to Project Properties in File Menu, there under Libraries u can see all the libraries that were imported..
like shown in the above picture, the other jar files i imported previously are noted as Broken reference.. So i just removed and it did the magic =D

Does the buildpath needs to reconfigured on local machine for a project checked-out through SVN?

This is my first time using SVN or for that matter any version control. So, I've been able to check out a selenium project on my local machine. This source code was working fine on the other machine(my friend's), but on my machine it throws hundreds of errors such as "BeforeClass cannot be resolved to a type, Assert cannot be resolved to a type" etc.
I do know that this error could be because the required selenium jars may not have been setup in the build path. But, I can see all these selenium jars in the "lib" folder.
So, I want to understand if I need to reconfigure the build path. By the way, don't the project settings etc come by default as the same code works perfectly on other machine, which means the build path must have been configured there.
I know its a very basic question, but I assure you that I'm a naive coder.
Thanks for your help.
Note: I'm using Eclipse IDE
Eclipse's project configuration files (eg, .project, .classpath, .settings, etc) are designed to be checked in with the rest of the project. If done so, whenever the project is checked out to a workspace Eclipse will automatically use them to properly configure the project. Check that your friend checked in those files; if not, ask him to.
It looks like you did not add Eclipse project metadata files(.project,.classpath) & .settings folder to your source control system, so Eclipse doesn't know what your build path is or whether it is even a java project.
Go back to your other computer and look for the following files in your original project root...
.project
.classpath
.settings/*
Make sure all are present in Source Control System.

Remote Play framework and Eclipse

I have a play framework project which run on remote server.
I'm trying to configure eclipse to work remotely on the project.
since no build is required my requirements are to be able to edit the project files from eclipse and automatically save on server, auto complete and debug.
I've installed Remote System Explorer on eclipse and setup a remote ftp connection to my server.
The play environment on my server is under
/play-2.0.2/
My project path is
/play-2.0.2/test
In RSE I clicked on /play-2.0.2/test and 'Create Remote Project'
Now in Java perspective I can browse through the project, change files and then automatically save to server.
My problem is auto completion of play framework library doesn't work well since all the reference are to /play-2.0.2/repository/...
any idea how to solve it? I tried to play with the build path but no success
Thanks!
So, I was looking into achieving the same thing myself.
The problem you are experiencing is due to the fact that the .classpath file has absolute values. While for me, besides the symlink that doesn't work between two different kinds of O.S., I thought on another two solutions:
Use sed to rewrite the classpath on the .classpath file after it's generated
Use a "classpathTransformerFactory" for the sbt eclipse command
I haven't had to deal with it (it's more of want to than whatnot) as soon as I do, I will explore the two options and post details. I just leave the answer here in case someone wants to pick up where you left.
Another thing is:
Seen that sbt picks up the libs referenced in build.sbt, downloads the jars and puts them in the ~/.ivy2 directory, if you use any of those methods to change the reference from the remote machine to the local one, you would need to make sure that the same libs are on the local ivy cache. So, just as I wrote this, another idea came to mind:
sbt eclipse or play eclipse or activator eclipse [it should be the same] on a local environment, and on the remote one, then, transfer the .project and .classpath files from the local to the remote, and see what happens (if it doesn't work, scan them for absolute and incorrect paths that might need to be changed)
Sorry for the unproved answer, still I think it's better than no answer.
Cheers

Why are packages suddenly greyed out in Eclipse?

I have been working on an inherited webapp project and a few hours ago I exported to war file. I imported from the war file on another system (Ubuntu) and noticed all the project's packages are greyed out. Some I can expand others I can't.
Deploying the project in a container works fine, and does show the updates I made, however I can't get at the packages, or files I edited.
I have researched online and gotten no closer to an answer so far.
Any reason as to what's happening? I use Eclipse 3.7 on both systems.
A war file only contains compiled classes. You won't find your source files in a war file. That's not what it's used for.
If you want to share code and project files between two machines, use SVN, Git or another version control system. Even with 1 machine, you should use it anyway.

eclipse projects and compiled data

in my Java Eclipse project that contains JUnit tests, I also have a package "resource" that contains all input data used for the tests. But when compiling JUnit tests, the Java compile also data available in resources, so I find the same data in the "bin" folder. Is there a way to avoid this?
thanks.
If you have a particular package within the source path you want to exclude (your resources folder for example), you can right click on the package and select: Build Path > Exclude.
This will tell Eclipse that you don't want to include that package as part of the build.
This is making a couple of assumptions: that you're using Eclipse Helios (because the option might be different in older versions), and that the resources are stored in the same folder as your regular java source files (because if resources is in a folder by itself, you can remove that entire folder from the build by using Build Path > Configure Build Path -> Source tab.
Update:
After the discussion in the comments regarding why you would or would not want to copy resources into the bin directory:
The contents of your bin directory should be ignored and not checked into to a version control system (when using CVS, bin should be an entry in the .cvsignore file)
The resources are only duplicated on your local machine, which is fast and hard discs are big. I'm not sure you should be worrying about this
If you're using Class.getResource to access those resources, they need to be on the classpath somewhere. The bin directory is as good a place as any
So, realistically (barring some unknown, like the files are hundreds of gigabytes or something), I don't think you need to be concerned about excluding these files from the build.