How to use Eclipse to open an existing project

Source: Internet
Author: User

When you start using Eclipse, you'll find the question of how to open an existing Eclipse project and start looking for a long time in the menu. In fact, the results of eclipse generation are not as open as vc,jcreator, and to open other existing projects under the Non-workspace folder, you can open the menu file->import→general→existing project Into space. In select root directory, select the folder you want to open. At this point, if you choose Copy existing project into workspace the files will be copied to workspace at the same time.   The first step here is to ensure that eclipse two files are guaranteed. Classpath and. Project is still there, otherwise it cannot be imported, that is, the import of Eclipse only recognized their own home things. If the project you want to open differs from the configuration of eclipse, it can cause problems at run time. The workaround is: Open the menu project→properties modify. The main need to modify is the Java build path entry.

How to use Eclipse to import and run the source code

Since eclipse is not used very well, we do not know how to import existing documents into the project, online research, and smooth solution.

My source storage address is: C:/Documents and settings/administrator/desktop/mobile QQ2007 official version/SRC create Eclipse project will not be mentioned, the establishment of the project file directory is: C:/Documents and settings/administrator/Desktop/MYQQ I am using the eclipse3.2.1 Chinese version, import source into the workspace, select File--Import, and then select the file system, and then select the source to import the path can be imported. After importing the Properties dialog box, open the project, select the directory you want to compile in the source code in the Java build path, and you can set the output path, and then compile the imported source files after you click OK. Very convenient. Because I import the source file There is also a directory, so this will be an error, because the import will be organized as a package, so the following error is reported: The declared package does not match the expected packages Appendixastringer.javathinking in Java/appendixaline 12,006 November 11 14:11:203870 Then just add the package command to the front of the program, for example, for the above error , you need to join the package Appendixa. After compiling and then running, you need to be careful when you run it, it needs to be called by package under the working path, for example, my working path is/thinking in java/c04/, under the Simpleconstructor.java file, after compiling, I need to/thinking In the Java directory, enter: Java C04. Simpleconstructor, this includes the correct package structure to work properly. Does not contain the correct package structure or is not operating under the correct path, the following error is reported: Exception in thread "main" Java.lang.noclassdeffounderror:c04/simpleconstructor Note that the directory structure is/thinking in Java/c04/simpleconstructor, so to run the following command in the thinking in Java directory, be careful to add the packet structure. The results of the operation are as follows: D:/javacard/thinking in Java>java c04. Simpleconstructor Creating Rock CreaTing Rock Creating Rock Creating rock Creating rock Creating rock Creating rock Creating rock Creating rock Creating Rock

This is a program about object initialization and construction.

PowerWord found only to maximize and minimize, click on the bottom right corner of the icon will not appear PowerWord interface, the taskbar has this icon, only the taskbar on the right button to maximize the use of PowerWord, then click on the bottom right corner of the icon to open the word PA, where it went to, this problem troubled me for many days. Today to Baidu up a bit, found that the original Kingsoft has been in the window interface outside, you must use the keyboard to drag back. The first time this problem came across.

On-line access to information on the way people write something, feel good, as follows: How to use Eclipse Import and run the source code

How to use Eclipse to import and run the source code (original Oh, if reproduced, please specify the author forest077)

There are many articles on the internet about Eclipse Configuration and development primer, but it's either superficial or very advanced, but seldom see a description of how to import someone else's source code into your own eclipse environment to compile and run. As a beginner, to learn some excellent online source is the only way to improve, but Eclipse is not as easy as VC and Delphi, for many beginners, it seems to be too difficult point. In the case of not finding a good introduction to eclipse, in order to run the Java source code downloaded online, I quite spent some time to find out how to correctly import the source code and run the method, not alone beautiful, special contribution to share with beginners. Operating Environment: Java EE 5.0 Eclipse 3.2.1 Chinese source code use case (all Java application): Emulation Windows Notepad repeatedly see the above two source code can be found on the Sadie Web. About JDK configuration, installation, and installation of Eclipse This article does not repeat, the reader can easily find the relevant information. This article will only talk about using Eclipse to import source code methods. First make sure that your workspace is created and that the directory where the workspace is located on my machine is "e:/workspace". The source-code storage path is assumed to be "My Documents/cai/java/an imitation Windows Notepad" and "My Documents/cai/java/look/kyodai". Here's how to import the source code. Select the menu "File/new/project" and select "Java Project" to bring up the "Create Java Project" dialog box. Enter "project name" in "Create Java Project", the project name can be any name, not the same name as the main class. This is assumed to be "Notepad". There are two radio buttons in "content" that you can use as needed. Where "Create new project in Workspace" creates a new directory in your workspace, the directory name is the same as the project name, "Create Project from existing resources" can be compiled and run directly in the directory where the source code is located, and the generated class file will be stored in the source directory.
Here's how to "create a new project in a workspace." In content, select Create new project in workspace and click the Finish button. The Notepad directory is now generated under E:/workspace. The following need to import the source code to work space. Select the menu "File/import" and select "File System". The File System dialog box pops up. In the "from directory" select the source directory "My Documents/cai/java/a copy of Windows Notepad", tick all the. Java source code, the other garbage do not choose. There are two choices below: The dialog box has two options, if you choose "Create a complete folder structure", you will be in the source of the path to the full creation of the directory in the workspace, the creation will be due to the Main method class path is not the same as the icon in the Package Explorer display fork, can not compile successfully; Create only selected Folder ", you will be able to compile successfully by importing all the files in the workspace created directory without preserving the original directory. If you select "Create a complete folder structure", after the import is completed, select the Menu "Project/Properties/java build Path/Source code", click "Add Folder", the directory step to open, until the source code is located in this directory, tick on the directory. Click OK to pop up the prompt dialog box. Note that the parent directory does not tick, otherwise it will error. In this way the source code imported by this method can also be compiled and run. Note If the source code contains subdirectories, there will be import in the main program ... Statement, you should pay attention to the directory level after import, and when choosing the Java build path, tick the parent directory name indicated by import. For example, repeatedly look at the code in the subdirectory Topbar, in the main program has the import Kyodai.topbar statement, then you have to tick "my document/cai/java/See/" This level of directory, and not the source of "my document/cai/java/repeatedly see/ Kyodai "directory. In the source code, the author has all the source code has been packaged into a jar, at this time only need to add the jar package and do not need to import other source code can be run (but not debugging, because the jar package does not contain the source code). After you create the new project, select the Menu "Project/Properties/java build Path", click on the "library" page, click the "Add External Jar" button, select the source code comes with the jar package to run.
The following describes how to create a project from an existing resource. In the Create Java Project dialog box, click the Next button to bring up the Java Settings dialog box. In the Java Settings dialog box, select the Libraries page, select Add jar, and if the jar package supplied with the source is not found, select Add external jar. In general, if the jar is in the correct directory, you can find it in the "Add Jar" section. Double-click the jar package that appears to add it. If you do not need additional library support, click "Done".
In this way, projects created using the two methods above can be compiled and run. The following describes how to run it. Select the menu "run/run" to bring up the "create, manage, and Run Configuration" dialog box. Select from the list on the left based on the type of source code. The two examples we use are Java applications, so double-click Java applications to enter a running configuration on the right side of the dialog box. If a new project has not been run yet, the default value for the Project column on the right is the project you just created. Enter the name of the run configuration in the Name field, which is recommended to be consistent with the project name (or inconsistent) and cannot be the same as other run configurations. Click on the "main class" bar to the right of the "search" button, generally only a main class, in the pop-up dialog box, double-click the following column of the main class can be. If you need to use the other main method as the program entrance, you can tick the "main class" column below the two check box, select a different entrance. If you need to add special environment variables, such as some source code that may need to be added classpath environment variables, you can add them in the Environment page. The contents of the run configuration are also reflected in the Debug configuration, running and debugging using the same configuration.
After you have created a bunch of new projects, there will be a bunch of clutter in the package explorer, some of which you need, some that have already been discarded, and you can delete the unused items by right-clicking on the item and selecting "Delete". To remind readers here, the deletion of the dialog box has two options, ask you whether to delete the contents of the project directory, the default is "Do not delete content", if you choose to delete, then the entire directory is deleted, if your directory is useful, then you have to cry. After removing the useless items, the extra configuration in the Run/debug dialog can also be deleted by right-clicking on the unused configuration name and selecting Delete.
Well, this is my beginner's experience of Eclipse, hoping to help the vast majority of beginners who want to use eclipse and worry about its cumbersome.

Encountering Java.lang.NoClassDefFoundError errors can be resolved as follows:

You should check your environment and your actions in this way:

1. Is your file name right? Java requires that your files correspond strictly to your class name. such as public class helloworld{..... Then the file name must be Helloworld.java, look carefully!

2. Do you have the main method in your program? Parameters or something, right? The declaration of the main method should be this: public static void Main (string[] args) In fact, if you do it with a development tool, it's not wrong. If you use UltraEdit and the like to write programs, just a word do not change the copy it!

3, remember, Javac followed by the parameter is the file name, but Java followed by the class name! This is when I started to learn Java is a mistake, Java Helloworld.class, and then the error. Later only to understand, it should be Java HelloWorld.

4. Have you set the classpath? Not only is the content to be set when installing the JDK, it is generally better to set a directory yourself to store your own class files. such as the D:/class directory. Set classpath=%classpath%;d:/class Then, copy the Helloworld.class file to the D:/class directory now, and then Java HelloWorld should be OK.

5, combined 3rd and 4th if your class belongs to a package, such as a class sony.test.HelloWorld, then according to the directory I said in 4th, I should put the Helloworld.class file to d:/class/sony/ The test/directory. Implementation should refer to the 3rd, according to the class name: Java sony.test.HelloWorld.

Do you understand? I can't think of any reason why this error message has been created! If any brothers think of it, add it! In fact, if you use some of the better programming tools, there is no chance to encounter this error, at least I am using VisualAge for Java, there is no such thing.

Well, don't say, good luck to the comrades! After the first door, the back is relatively simple!

Original link:

How to use Eclipse to open an existing project

How to use Eclipse to open an existing project

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.