eclipse import project from tomcat webapp - java

i have a project in tomcat,and use startup to set up it.
i want to import it into eclipse in order to debug it,and then i try to import project like this:
it displays no project found, maybe it does not have .project file
how could i import it correctly and conviently? there are only class in web-inf,so how could copy it?

Do the following:
Create new Dymanic Web Project in Eclipse
Right click -> Import -> General -> File system, on this project.
Choose source directory.
And check Java Build Path in your project to be sure your Libraries correctly loaded.

There is no direct way to do this, however...
Perhaps, the simplest way to do this is the following:
Download Eclipse Java EE
Create a Dynamic Web project
Copy the contents of your webapp (or war) to the WebContent folder
If the project contains Java sources andyou have access to them add them (including the package structure) to the src folder.

Related

Importing existing java dynamic web project into Eclipse

How can I import a java web project into Eclipse IDE. in the import dialog there is only a war file upload can be selected. But I couldn't find something like import a project.
So how can I import an existing java web project. Thank You!
You can always import your project that you have made it, previously with Eclipse using the "Existing Project into Workspace" option.
It will directly load all the packages of your Dynamic web Project, related to Eclipse Folder Structure.
And if you want to import a Web Project which is may be made with using other IDE than Eclipse and if it is pure web project than use WAR import, because it is a complete way to import any web project. For this prerequisite is that when Exporting the project you have it in WAR file.
Note:- I have not worked with other IDE than Eclipse that much. So I can say that there may be others who knows how to import project created from other IDE than Eclipse.
Use New -> Java Project -> A window will open -> Uncheck Use Default Location -> Browse to the root of the project -> Finish
You can import existing projects(any type) from below location in Eclipse
File > Import > Existing Project into Workspace
Using that 'existing projects into workspace' you have already highlighted? Assuming you're talking about an existing Eclipse project, and not about a project which has only code. Otherwise you just create a new web project and you copy the source to it.

Import project (jar) into Eclipse

I got a .jar file which I need to import into Eclipse. However, I don't want to have the jar as a referenced library. I need the .jar to be included like a "normal" project, with packages(!) and .java files.
I tried to do the following:
New Java project -> Import -> General -> Archive File. In this case, when I place this jar also as a referenced library, it is imported but with .class files.
New Java Project -> Import -> General -> File System. Imports the .java files, but the packages are lost and are normal folders. Also, the files are somehow strange, because the "j" in the icon looks differently, and errors are not noticed (no underlining)
Importing "Existing Projects into Workspace" doesn't work at all, it says that there is no project. I also tried to import the jar as a zip after extracting it, this gives me the -java files, but it destroys the packages.
Does anyone know how to import this correctly?
I have managed it this way:
New Java Project -> Java settings -> Source -> Link source (Source folder). There I added my decompiled jar and it was imported correctly :)
You can also create a new Java Project and then do File -> Import -> General -> Archive File. This will save you a step of unzipping your jar and adding as a linked source folder.
You cannot import a jar that way, unless it has the source code packed in the jar. If you really need the source code, you'll have to find an archive somewhere. But of course, not everyone is willing to share his source...
I tried the below and it worked.
Create a New Java Project
Goto File > Import > General > Archive File
Select the required Archive file(.jar in this case) from your local system.
Select the project you created in Step 1 and click Ok
This will save you a step of unzipping your jar but if there are .class files, eclipse won't convert them to .java files. This has to be done seperately.
Below helps in all recent eclipse.
Please try below eclipse plugin to import jar as project :
Step 1) Eclipse Help > Eclipse Marketplace
Step 2) Install the plugin "Import Jar As Project"
Step 3) Restart Eclipse
Step 4) File->Import->Other->Jar without source
Step 5) Select a jar/war file and click finish
New project will be created from the jar
https://marketplace.eclipse.org/content/import-jar-project
Thank You.

Can you import a non-archive project directory in Eclipse?

I read this article which shows how to import/export projects in Eclipse (although it seems a little outdated and I'm using 3.7 Indigo).
To export a project, you go to File >> Export and it creates some kind of "project archive" file on the local file system. You could then email it to someone else, who could then import the archive as a new project or into an existing project.
But what if you don't have an "archive" file to begin with?!? What if you just have the project files and directories but without all the Eclipse-metatdata (.project file, etc.)? Is there anyway to tell Eclipse to look at, say:
/home/myuser/some/path/to/project/root/
src/main/java
SomeObject.java
build.xml
...and get it to read that as a new Java project?
Try the steps below:
Create a Java Project in Eclipse as below:
Load the project contents from your file system as below:
Hope this works for you.
.project and .classpath files are the base of the project structure. Without a .project file Eclipse won't recognize your project. The .classpath is important too but that one changes between environments. Should you use the files from another environment you'll have to reconfigure some settings.
Rather than emailing code, I suggest you use a Version Control system and, also, some Eclipse plugins. SVN + Subclipse for example.
If you trully want to send the project to another person just send him the project's folder and import it as an existing project by doing right click on the project explorer and selecting Import > Existing Project into workspace.

Getting a java.lang.ClassNotFoundException: org.jsoup.Jsoup

I am running my app on google app engine. All I have is a simple servlet that is trying to use Jsoup. However when I run the application I get java.lang.ClassNotFoundException: org.jsoup.Jsoup.
I am using Eclipse so I added the jsoup jar file in the Java Build Path -> Libraries
You need to put the Jsoup JAR file in the /WEB-INF/lib folder of the webapp. That folder is covered by webapp's default classpath. Also, Eclipse will automagically put all libraries in /WEB-INF/lib folder in the buildpath of the project, you shouldn't need to do that manually. Of course I assume that the project is been created as Dynamic Web Project.
Another way to add the .jar is to right click on your project, and choose Properties -> Java Build Path, click the Libraries tab, then click Add External JARs... This will allow you to browse to the path of the .jar file you wish to add.
Also make sure your import org.jsoup.Jsoup; imports are after all the application imports such as
import com.google.gwt.core.client.GWT;
Having the JSOUP imports before those other imports caused errors for deploying an application at one point for me.
I had the same error now on my Android project. To Fix this on Android, you need to create a lib folder and put the .jar file there

Questions on how to import google-api-translate-java.jar

I am now going to use the .jar file on http://code.google.com/p/google-api-translate-java/. However, after I download it, I tried to import it in my current project folder (in Eclipse)
the two import statements
import com.google.api.translate.Language;
import com.google.api.translate.Translate;
always get complained by the compiler saying couln't find such class
Could any one help on how to correctly import this .jar file into a project in Eclipse?
You need to add it to your build path. Right-click on the project in Project View, select Build Path->Configure Build Path, then Libraries tab. Now, use one of available options there to add a JAR.
Use "Add JAR" if you copied the jar to your project folder or "Add External JARs" to add it by poiting to a path in filesystem. (Anyway, it is better to copy the jar to the project folder, in which you want to use the jar).
HTH
see How to import class into existing Java project, with Eclipse
Copy the google-api-translate-java-0.92.jar file to your project /WEB-INF/lib/ folder and refresh your project (right click on project and select "refresh").
Google Translate API v1 is deprectaed and will shutdown soon.
You can use Google Translate API v2 Java. It has a core module that you can call from your Java code and also a command line interface module.
Hy I have faced the same issue and fixed it
Step1: download google-translate-api jar file
step2: paste into your app library file
step3: Goto project structure > app > select dependencies -> then add path of your jar file...
Enjoy now you can acess google api services

Categories