How to set up the JavaEE First Cup tutorial in eclipse? - java

I'm going through the tutorial (https://docs.oracle.com/javaee/7/firstcup/creating-example002.htm). I have Eclipse for EE developers (4.6.3) with Glassfish (4.x) properly configured in it.
I see the project folder under glassfish4\docs\firstcup but I don't know how to import it since the instructions are for Netbeans. If I try to "Open projects from file system" or a general import I get just the folder structure in the workspace and not with the right "flavor":
Then Glassfish doesn't recognize this as a resource that can be added. How do I do this in Eclipse?

I was stuck with the same problem.
Here are the steps I took to make it work.
Skip the step where you have to open the firstcup project and build.
When you have to create the dukes-age project and the firstcup-war project, go to File > New > Maven Project.
Make sure the "Create a simple project (skip archetype selection)" option is unchecked. Click Next.
On the next page, you have to select an archetype. Choose "All Catalogs" and type glassfish in Filter and you will see the 2 archetypes you need for the tutorial.
On the next page, you need to enter Group Id and Artifact Id. For the dukes-age project, type firstcup.dukesage.resource in Group Id and dukes-age for Artifact Id. Click Finish.
You will notice that there's an error in your pom.xml file. Open it and edit by removing -SNAPSHOT from the line <version>8.0-SNAPSHOT</version>. Save.
Right click the project in Project Explorer (the left pane). Go to Maven > Update Project.
Skip the step to set the default URL for dukes-age. Instead, when you want to test your completed web service, go to http://localhost:8080/dukes-age/webapi/dukesAge/.
Note for the firstcup-war project. Before adding the project to the server, make sure you start Derby by running ./asadmin start-database inside glassfish5/bin. Otherwise, you have to remove the project from the server and add it back.
That's all. Other than that, everything is quite similar to the steps in the tutorial. Feel free to ask.

Related

installing packages locally for a new project in Java

I have downloaded a simple project from a Git repository and opened it in Intellij. A couple of the import statements are highlighted in red, stating "Cannot resolve symbol." The packages that cannot be resolved are: zaxxer, springframework.
Normally in Perl or Python I would fire up a dependency manager like CPAN and simply install them, but my understanding is that there isn't really any such thing in Java and that dependencies are resolved sort of on a project-by-project basis.
I have Maven 3 installed, and my project has a pom.xml file, for what it's worth. What should I do now?
If you have opened the project in IntelliJ you can right click the module and choose "Add framework support". Choose Maven there, if it isn't there then it is already enabled.
Then, simply open your pom file. When indexed there should appear an dialog in the lower right corner asking you if you want to auto import changes or just import them manually. Click on one of them and the dependencies will be added.
If you can't see this notification it may have already been shown, then simply press on the "Event log" in the bottom right corner and the notification should be displayed (with eventual other info).
Edit from OP: Solution was: 1) Turn on the view in View > Tool Windows > Maven Projects. There was no Maven project here, so I added it (selected the pom.xml). 2) As described in an answer at Failed to Read Artifact Descriptor: IntelliJ "In Intellij, go to File -> Settings -> Build, Execution, Deployments -> Maven Check the box, ‘Always update snapshots’
It's a little weird that "always update snapshots" isn't turned on by default for IntelliJ, but this got things working.

Project name not appearing in debugging Eclipse

I have cloned a Bitbucket project in my Eclipse IDE and I want to debug the project as a remote application.
However, in the debug window (->connect window), the project name is not shown.
Why do I not see it?
I am Attaching Screenshots where you create Debug Configurations for any Remote Java application.
Lets Go step by step:
Within Debug Configuration Window
You right click Remote Java Application > New
In the Connect Tab you browse the project in your Workspace (One you want to debug), Here in my case it is MyApplication
In Source tab You Find below details where you add any dependent projects with the project that you want to debug
When you say Add here, small dialog box comes up and here you can again choose Java Project, that would be one from your workspace.
I think doing this you would find your Project for Remote Debugging.
Hope this helps..!
I didn't see your problems related screenshots, but according to the situation you described, you can try the following method:
On the debugging of threads Right click it
--select Edit Source Lookup Path
--Select Add
--Select the Java Project
--choose the Java Project you worked with then click OK.
The other situation I think about is whether or not you don't have the jar that you're relying on for the project you downloaded
I had same problem. I had imported project as import project from file system. so it was not java or maven project for eclipse i guess.
i just did import as git project and tried again and it worked.

Configuring appengine-web.xml

I successfully cloned an web application project from Github to eclipse Luna.
When I try to deploy the cloned project to google app engine, eclipse does not recognise it as a web project. I realised that it was missing the appengine-web.xml file.
I created one under directory WEB-INF in War,
I saved it but when I try again to deploy, still eclipse says that the project is not an app engine project.
What could I be possibly doing wrong?
Since you do not provide the exact error message, I list several possible causes:
Right click on your project, select "Google" option, then "App Engine". Make sure that "Use Google App Engine" checkbox is checked.
In your build path, make sure that "Allow output folders for source folders" is checked and the correct folder is specified (i.e. "MyProject/war/WEB-INF/classes".
Make sure that you are logged in Google with the correct account before you try to deploy - your current account is shown in the bottom right corner.
UPDATE:
This error indicates that your project is not a Java project. Select Project Facets in Properties. On the right side make sure that on the left side Java 1.7 is selected.

Java project from existing ant build file doesn't appear as in version control

I have a repository in which I have a simple ant project (only the src directory and the build.xml file). I did a checkout of this project in a local copy. Then I opened Eclipse, created a "Java Project from existing Ant build file" and it worked fine. I can build, clean, run, generate javadocs, etc. However, my problem is that the source files in the packages, as well as the project itself, doesn't appear to be under version control in Eclipse. I can work with it fine from Cygwin, but not from the GUI.
The odd thing is that I have several regular Java projects, on the same repository which are synced fine by Eclipse, so it's not a version issue.
When I created the projects that work, I had to go to Team->Share Project... and Eclipse told me that they were already under version control and updated its configuration. However, in this current case, this isn't working. Any suggestion please?
EDIT:
I'm using svn 1.8.
UPDATE: I tried creating a regular Java project, and this time the version control looks fine, so it appears it's an issue related only to Java Project from Existing Ant build file.
The problem is that Eclipse doesn't know your project is using Subversion as a version control tool. You did a checkout outside of Eclipse, then you set up Eclipse as if this was a non-version controlled project.
To get Eclipse to recognize the project as under Subversion, you need to let Eclipse know. This means you should have said "File->New->Project, and select SVN->Checkout Project from SVN in the new project wizard. Then, Eclipse would have checked the project out in Subversion for you, and Eclipse would understand this project is in Subversion.
Unfortunately, I am not quite familiar enough with Eclipse to know how to tell Eclipse that the current project is really under version control. The best I could come up with was:
Right-click on the project and select Team->Share
Say this is a Subversion project you want to share.
Select the Repository to use
Select the folder where you want this project, and select the current folder.
You get the following warning:
Warning: The specified folder already exists in the repository. If you continue, that folder will be checked out to the existing location. Do you want to continue?
Your project will now be "checked out" over your current project. Everything should be okay because the files you have either match what is in Subversion or are modified versions of what is in Subversion.
You will be then asked to use the Synchronized view. Check "Yes", and then switch back to the Java view. Eclipse will now know your project is under Subversion and everything should work fine.
Note the use of Shoulds and Coulds. This is my way of saying that the advise given is done on an "as is" basis and I am not responsible for any damage done by following this advice, so please don't sue me.
It's basically your standard open source license.

import all projects from svn repository folder

I have that problem:
I checkout folder (myFolder for example) using tortoise svn.
import->existing projects into workspace
after it eclipse found a lot of projects(about 50) from different locations of myFolder.
BUT
eclipse doesn't understand that these projects from svn(no svn menu if make right click on any file and select team submenu)
I attempt to import-> team project set but after it in eclipse I see myfolder only. it is just folder - not projects. I cannot to compile it and use other features.
I think you are understand my problem.
Can you help me?
Make sure you have installed a subversion plugin for eclipse which is is compatible with the version you have for tortoise, i.e the eclipse plugin you actually have - if any - is able to read the .svn meta data which was created by the tortoise client. This can happen for example if eclipse plugin is 1.6 and tortoise client is 1.7 or above.
When eclipse shows the ~50 projects deselect all and select only the one(s) you want to import, when passed a folder for importing an existing project, eclipse searches recursively for all folders containing a .project file and displays them as projects to be imported. Make a refresh (F5).
EDIT
From http://tortoisesvn.net/tsvn_1.8_releasenotes.html#compatibility
Local Client Compatibility
Subversion working copies are sometimes accessed using several different clients, e.g. TortoiseSVN, AnkhSVN, and the svn command line client. Because the working copy format has changed with this release, 1.8 clients cannot access an earlier working copy without first upgrading it. Pre-1.8 clients cannot access 1.8 working copies at all and there is no downgrade option
Please upgrade your eclipse svn-kit to the latest version, use this update site.
If you have already checkout your projects, import them in eclipse then follow below steps.
Right click on your project go to Team --> Share Project --> Select Repository type. Do next fill in required information and it should work.

Categories

Resources