I'm learning Java EE at the moment and will probably have many questions for you
Now I discovered a strange issue with the javax-packages. I'm learning Java EE using the official Oracle tutorial.
The first practical example is a "hello username" Web Application with a managed bean, that uses Named and RequestScoped annotations. It's absolutely no problem, as long as the project folder lies under glassfish4-directory, but if i try to move it, the compiler cannot find the javax packages for the annotations.
It does not matter, if I right click on the project in NetBeans and choose "Move", or delete the project, move the folder manually and then open it in NetBeans again.
It's absolutely no problem, as long as the project folder lies under glassfish4-directory
You shouldn't be having those projects there. I think what's happening is when you have your project there, the compilation classpath is picking up the jars (which include the ones containing those javax classes) in its classpath.
When you are building the project (either through an IDE or a build tool like Ant) just make sure that you have the compile time classpath setup such that it includes that relevant jar files required for your project (like the javax ones). How you do it depends vastly on the IDE you use or the build tool you use, but their documentation usually explains those details.
My question is now: where does the compiler look for those packages? Doesn't it search them in the java-directory? I really don't see the difference, because those packages are global, aren't they? Like <stdlib>-library in C++?
I now looked at the classpath settings in NetBeans and it always stays the same, no matter if I move the project folder, or not. It always looks for those packages under glassfish4 directory.
Also, there is an error message, when I open the project from a path, other than /glassfish4/...:
"Project Problems. One or more project resources could not be found."
When I click on "Resolve problems" it says
"Parent POM file is not accessible. Project might be improperly setup. The parent POM with id org.glassfish.javaeetutorial:jsf:7.0.1 was not found in sources or local repository. Please check that <relativePath> tag is present and correct, the version of parent POM in sources matches the version defined.
If parent is only available through a remote repository, please check that the repository hosting it is defined in the current POM."
Joined: Mar 17, 2012
So your project is using maven? I'm sorry but you should stop and read up on classpaths and then read up on maven before continuing. You shouldn't be using Netbeans' classpath if you are using maven because all your dependencies should be in the pom.