specify class file destination eclipse ide - java

I am using Eclipse - Indigo for creating a servlet. I keep getting the following Specify class file destination whenever I try to create a new servlet.
How do I overcome this?

I faced the same problem.
First of all, try re-selecting your "Project", which is the very first row in "Create Servlet" window ('One' in your case). It worked for me.
If that doesn't work, give this a try:
Right click on project in Project Explorer. Go to Build Path> Configure Build Path which opens up "Properties" box. In the left-side pane of this box, go to "Java Build Path". Now, in the right-side pane, click on "Source" tab. Just above the "OK" button, you can see a text-box labelled "Default Output Folder". You can use "Browse" button to set desired location. I am attaching a pic for your reference:
For more details,
refer this eclipse documentation http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fref-properties-build-path.htm
That should solve your problem. Hope this helps. Thank you.

The problem may arise if you have not installed the "Web, XML, Java EE and OSGi Enterprise Development" software package. Simply:
Help > Install new software...
select "-All Available Sites-" under work with.
select "Web, XML, Java EE and OSGi Enterprise Development" package
install it.
Restart the eclipse and try again with servlet creation.

I had the same problem which was caused by an error in my web.xml (haed an unescaped &). As soon as I fixed th web.xml I could create a Servlet.

Related

Error in Eclipse: "The project cannot be built until build path errors are resolved"

I am a computer science student learning Java, so I do some work at home and at college on a mixture of Linux and Windows. I have a problem after copying a new project into the Eclipse workspace. The project shows up, but with a red exclamation mark and an error saying:
The project cannot be built until build path errors are resolved
How can I fix this? I tried the solution described here, but it didn't work.
Identify "project navigator" or "package explorer" view.
Right click on your project, select Build Path --> Configure build Path.
In the emerging window, you will find four tabs, select "Libraries".There, under "Web app libraries" (expand it), you will see the libraries added to the project's classpath. Check if all of them are available. If one or more are not (they'll have "missing" beside their name and a red mark on their icon), check if you need them (perhaps you don't); if you don't need them, remove it, if you need them, exit this window, look out for the missing jar and IMPORT it into your project.
Open the Problems view. You can open this view by clicking on the small + sign at the left hand bottom corner of eclipse. It's a very tiny plus with a rectangle around it. Click on it and select problems.
The problem view will show you the problems that need to be resolved.
If the message says "the project is missing the required libraries...", you need to configure your build path by right clicking on your project, selecting properties, then build path. Add the required jar files using the libraries tab.
-If there are other problems other than missing libraries, you need to post the exact problems here to get a precise solution.
If you can't find the build path error, sometimes menu Project → Clean... works like a charm.
In my case, all libraries in the build path were OK.
To solve it, I deleted all project metadata (.project, .classpath, .settings) and re-imported the project as a Maven project.
Right click your Project > Properties > Java Build Path > Libraries
Remove the file with red "X" (something like JRE...)
Add Library
That's how I solved my problem.
I also had this problem in my system, but after looking inside the project I saw the XML structure of the .classpath file in the project path was incorrect. After amending that file the problem was solved.
If not working in any case...then delete your project from the Eclipse workspace and again import as a Maven project if that is a Maven project. Else import as an existing project.
I tried all the previous given solutions, but they didn't work, but it works for me.
In Eclipse, go to Build Path, click "Add Library", select JRE System Library, click "Next", select option "Workspace default JRE(i)", and click "Finish".
This worked for me.
Go to Project > Properties > Java Compiler > Building
Look under Build Path Problems
Un-check "Abort build when build path error occurs"
It won't solve all your errors but at least it will let you run your program :)

Design view in Netbeans won't load

I started to learn swing and downloaded netbeans to work through the tutorials. Unfortunately, when I create a JFrame design view hangs instead of loading and the Navigator and Inspector panes just show up empty.
System details:
Linux Mint Maya
Netbeans version 7.0.1
java 1.6.0_24
Any ideas would be greatly appreciated.
In whatever editor/designer you choose, consider the approach shown here, in which the top-level container is created manually and one or more content panels are maintained in the designer.
look in the Netbeans View menu and choose "IDE log"
There may be an error message / exception there, that might give you a clue.
Reinstalling the nb-javac plugin fixed this issue for me.
I followed the steps here and it resolved my problem.
For me, this was caused by a "FormGuardedBlockError", because at one point in my project I copied all of the source out into Notepad++ and used that to replace the .java file, thereby stripping all of the //GEN-BEGIN and related directives.
You can close NetBeans, open the .java file in a plaintext editor and put these directives back by hand, but it may be easier to merge with an earlier version of your code (if you have one).
For more details, check out http://wiki.netbeans.org/FormGuardedBlockError
Menu->view->show edit toolbar fixed this for me , of course the file you select to edit must have jframe, added to it I think for design tab to appear.
Go to Menu -> Option -> Select "Java" from option windows tool
then Active

specified JRE installation does not exist

I'm trying to launch a server on my tomcat 7 on my eclipse indigo EE
and I get the following error:
"'starting Tomcat v7.0 server at localhost' has encountered a problem.
The specified JRE installation does not exist"
I checked the build path configuration and on the libraries section I have the
JDK7 as JRE System Libraray and when I check "Installed JREs..." the correct
path is there - "C:\Program Files\Java\jdk1.7.0_01".
What else can be done? Many thanks.
p.s. - I'm also using maven 3.0.3
Double click on the server to bring up the Overview.
Click on Runtime Environment.
Select the JRE from the dropdown list. You may need to set this up by clicking on Installed JREs and clicking Add.
If the instructions above did not help you can do the following:
1- from the run menu choose "Run configurations..."
2- Choose your maven run profile and then click on the "JRE" tab.
3- Select "Alternate JRE" and from the drop down select "jdk1.7xxx" (or whatever jdk you want to use"
you can also select the workspace default jre.
I was facing the same problem and this helped.
Go to the build file.
Right click on it.
Do the following as per the screenshots
Window-->Prefenerces-->Server-->Runtime Environment; like this....
Edit your Apache,and select your jdk dir....
Go to Properties → Java Build Path → Libraries.
Here you will see a red cross on the library whose path is not correct.
Select this library, click the Edit button, and change it to the correct path.
Here is a solution with pictures
http://javahonk.com/specified-jre-installation-does-not-exist/
It worked after running "mvn install clean -P prepare"
For Eclipse MARS, for maven projects.
After you install the new JRE as explained (for instance here: http://javahonk.com/specified-jre-installation-does-not-exist/), don't use your old configuration, BUT create a new configuration.
Updated the Java , JRE. so I have faced this same issue, I have tried all this but i continued with this issue. then after that, i have removed the server from application and then added new server and with that i have mentioned new JRE version now its working fine.
Open eclipse and find the server tab and try to open it.
There click on Runtime Environment
Select the JRE from the dropdown list to set this up by clicking Installed JREs and Add.
If you use Maven, try:
EclipseMavenJRE_1
EclipseMavenJRE_2
Window-->Prefenerces-->Server-->Runtime Environment;
like this....
enter image description here
Edit your Apache,and select your jdk dir....
It worked after updating Server Runtime environment JRE .
At my case, I've changed the JRE installed at Eclipse and still the messages came out.
So,
1 - Right click at the JBoss Server > Open Lauch Configuration
2 - Select tab Classpath and click "Restore Default Entries"
3 - Close the window and Right click again the Jboss Server
4 - Select Properties > General
5 - Click two times 'Switch Location' (it returns to [workspace
metadata])
6 - Click Apply and Close
Afterwards, a new right click at Jboss Server > Clean, and the Jboss Server stopped the message.
Hope it helps.

I get "Source not found" when debugging my Java code in Eclipse

I'm trying to debug my Java application in Eclipse however when I hit a breakpoint I simply see the following instead of my source:
If I change the stack frame in the Debug window then I can see the function name change in the tab - this is definitely my code, the line number is correct and I'm using the latest build but I still can't get Eclipse to show the source (despite it being open in another tab!)
I'm new to Eclipse and so I'm struggling to find my way around, but everything that I've stumbled across so far seems fine to me.
What might cause this to happen and how can I fix it?
Sounds like the 'source lookup path' section if you edit the debug configuration isn't setup correctly?
Click on "Edit Source Lookup Path" button and then click on Add button then Java Project and include your imported project .. Hope this will solve your problem
I also had this issue in MyEclipse Blue. I resolved it by following these steps:
Debug the project.
Right click on the Thread (Which you will see in Debug tab) and click on the "Edit Source lookup"
New window will open and hit the "Add" button and Select the "Java Project".
Get all the project that is listed over there.
Restart your server.
I had similar problem with my eclipse maven project. I fought with this issue quite a long time then I tried to rebuild projet with
mvn clean eclipse:eclipse
and it helped.
When I faced this problem for the very first time, I've already done all the steps mentioned here. Curiously, my problem happened when I've copied a project into another place. Anyway, the debug starts to work without warnings, after simply remove all breakpoints that was originated from the original project.
Sorry about my English , I'm not fluent.
We had the same problem and none of the suggestions above worked. What did work, was deleting the local workspace and from Eclipse checking out from the repository again. The problem occured for everybody previously working with Netbeans and making the switch to Eclipse.
Try this:
Select Project
Right click
debug
Debug configuration
Select Source Tab
Click on add button
Select Java Project
Add your project there with check box
For local projects I've solved it by selecting the "Resolve Workspace artifacts" checkbox in the Debug Configurations.
This is a common error while debug in eclipse. You can fix it through edit source look up. But make sure once you attach the Project You need to stop the server and again start in Debug mode. It will work.
Here is the detail steps :
Click on "Edit Source Lookup Path" button .
Then click on Add button.
Select Java Project and include your imported project
Then stop the server and start it in Debug mode and hit your service. It will work.
After trying most of the solutions here, try this too once -
Close all the .java files from the editor, in fact, close all unrelated projects in eclipse.
And try running the Debugger.
I solved this problem by adding the class file into the src folder within the project. Hope this method may help.
I got this error when I was running my server using a maven tomcat plugin. When I deployed using my configured server in Eclipse (generating a war file and copying it into my tomcat directory), I didn't have this issue anymore.
In your debug configuration add goals as "clean install"in the maven build con
This is an expansion on JAB's answer:
Click "Edit Source Lookup..." > Add... > Workspace Folder > Project > select your folder > check Search subfolders box > OK.
In Eclipse:Window-->Go to preferences-->Java-->Click on JRE-->Edit--->Restore Default and click on Finish.
Update your Project before Debugging the code!
Alas! It worked for me.
This occurred to me when my working git branch is updated from code in master branch. I have already run mvn clean install after the pull, but seems I had to update projects after the maven build so that project source code and JAR build code gets synchronized.
Right click on your project -> Maven -> Update Project, then select all the
maven modules available and press OK. This resolved the issue for me.
I was facing same issue. After banging my head for several hours, I finally noticed that although Maven was building the project successfully, the source file I was trying to step into had an incorrect package statement and that is why the 'Source Not Found' eclipse problem was happening. When I corrected the package statement and rebuilt the project, the debugger found source file and stopped on my breakpoint.

how to add javaDoc to my Java code in a NetBeans based project?

How can I add JavaDoc or other document to netbeans ?
I try with this way :
Tools >> Java Platform >> JavaDoc Tab >> JavaDoc.zip (in my desktop)
but in editor when I press Ctrl+Space in tooltiptext this message shown :
Javadoc not found. Either Javadoc documentation for this item does not exist or you have not added specified Javadoc in the Java Platform Manager or the Library Manager.
I tried restarting NetBeans but this was the result:
try this in NetBeans IDE
Choose Tools > Java Platform Manager from the main window.
Select the platform to which you want to add Javadoc in the left panel of the dialog box.
In the Javadoc tab, click Add ZIP/Folder and specify the location of the Javadoc files.
Click Close.
Hope this helps.
If you are using maven in your project then follow below steps to attach Java docs for your attached libraries.
Right click on "Dependencies" folder of your project.
Then choose "Download javadoc" option
It will download javadoc of your libraries and attached it.
Now when you will press ctl + space then you will see docs for that library.
and If you want to add javadoc for particular library then follow the options as suggested by Himanshu Soni.
You can't usually just add the javadoc zip as a separate library (at least this hasn't worked for me in the past.) In the libraries section you need to select the library you want to add the Javadoc for and then add the Javadoc jar for that specific library.
Restart Netbeans then that should work. Though of course if there really is no Javadoc for that method you still won't get any (I've fallen into that trap a couple of times before!)
You followed the very right procedure, I've been threw this right before I write this answer, and as for this is the first result that shows up when you Google the problem, I think that many people will find it handy and save their time, the solutions is:
UNZIP the JavaDoc.zip file that you are referring to ( which is supposed to be jdk-7u4-apidocs.zip for JavaSE 7 docs) and repeat the same procedure, which is Tools --> Java Platforms --> Javadoc ( tab ) then press " Add Zip/Folder, and point to the unzipped folder instead of the zipped one, restart NetBeans, and it will work smooth and direct.
You should download the docs file from the following link:
http://www.oracle.com/technetwork/java/javase/documentation/java-se-7-doc-download-435117.html
After completing the described operation, you will have your javadocs available offline, and you don't need to be connected to the internet to know about APIs.
Best regards brother.
"Tools >> Java Platform >> JavaDoc Tab >> JavaDoc.zip"
The problem with above step can be solved easily by moving down following two path already added in content panel as shown below.
Step 1-
Goto: Tools >> Java Platform >> JavaDoc Tab
and Add ZIP/Folder you want to add.
Step 2-
Step 3-
That's all and if zip file doesn't works the extract first and then add it.
I had the same problem, and I solved it by removing all URLs and adding only the apidocs.zip downloaded from oracle. After that restart your NetBeans.
Before test whether it works be sure the method you are looking for actually exists within the apidocs. Open index.html and make a search for that particular package.class.method you need.
If it doesn't work, try to manually copy the apidoc.zip to the docs directory of netBeans:
C:\Program Files\NetBeans 7.1.2\java\docs and then retry.
this help me:
http://wiki.netbeans.org/FaqJavaDoc#Adding_the_JDK_Javadoc_to_the_NetBeans_IDE
try it, maybe help
Using a Maven project inside of Netbeans v8.02.
First, view your project via the Projects window;
Expand your project's Dependencies folder
Right-click the desired *.jar file
Click download javadoc
Done!
This worked for me, I manually copy the apidoc.zip to the docs directory of netBeans: C:\Program Files\NetBeans 7.1.2\java\docs and then restart my netbeans.

Categories

Resources