File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Javax-packages are not found, when moving a project to another directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Javax-packages are not found, when moving a project to another directory" Watch "Javax-packages are not found, when moving a project to another directory" New topic
Forums: EJB and other Java EE Technologies IDEs, Version Control and other tools
Author

Javax-packages are not found, when moving a project to another directory

Fred Fuchs
Greenhorn

Joined: Dec 17, 2013
Posts: 3
Hello everyone,

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.

I hope you can explain, why that happens.

Thanks a lot in advance!
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10242
    
168

Fred, welcome to the forums.

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 Blog] [JavaRanch Journal]
Fred Fuchs
Greenhorn

Joined: Dec 17, 2013
Posts: 3
Jaikiran Pai, thank you for your answer.

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++?

And how can I set the classpath in NetBeans?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10242
    
168

Fred Fuchs wrote:

My question is now: where does the compiler look for those packages?

The compiler will look for them in the compile time classpath. How you set up the compile time classpath depends on how you compile and what tool you use for compilation.

Fred Fuchs wrote:
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++?

For standard Java API it does use the JDK, but some of these javax classes are not part of the JDK. See this topic for an explanation http://www.coderanch.com/t/466100/GUI/java/javax-stand.

Fred Fuchs wrote:
And how can I set the classpath in NetBeans?


I don't use NetBeans and don't have knowledge about how it's done. But this documentation might help https://netbeans.org/kb/docs/java/project-setup.html#projects-classpath.

E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
You can also read more about the classpath here: http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html
Fred Fuchs
Greenhorn

Joined: Dec 17, 2013
Posts: 3
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."
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
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.
 
Consider Paul's rocket mass heater.
 
subject: Javax-packages are not found, when moving a project to another directory