Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2007. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Moving and copying Java elements</title>
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
<h1>Moving and copying Java elements</h1>
<p> In this section, you will use refactoring to move a resource between Java packages.&nbsp;
Refactoring actions change the structure of your code without changing its
semantic behavior. </p>
  <li> In the Package Explorer view, select the <em></em> 
    file from the <em>test</em> package and drag it into the <em>junit.samples</em> package. 
    Dragging and dropping the file is similar to selecting the file and
    choosing <strong>Refactor &gt; Move </strong>from the context menu.
  <li> You will be prompted to select whether or not to update references to the
    file you are moving. Typically, you will want to do this to avoid compile errors. You can
    press the <strong>Preview </strong>button to see the list of changes that
    will be made as a result of the move.
<p>Press <strong>OK</strong>. The file 
    is moved, and its package declaration changes to reflect the new location.</p>
    <p> <img src="images/editor_mytestcase_moved.png"  alt="File moved to junit.samples package"> 
    <li><p>Use <strong>Edit &gt; Undo Move</strong> to undo the move.</p></li>
  <p>The context menu is an alternative to using drag and drop.&nbsp; When
  using the menu, you must specify a target package in the Move dialog, in
  addition to selecting the update references options you've already seen.</p>
    Select the <em></em> file and from its context menu, select <strong>Refactor 
    &gt; Move</strong>.</li>
    <li> In the Move dialog, expand the hierarchy to browse the 
    possible new locations for the resource. Select the <em>junit.samples</em> 
    package, then click <strong>OK</strong>. The class is moved, and its 
    package declaration is updated to the new location. 
    <p> <img src="images/move_dialog.png"  alt="Move destination dialog"> 
<P class="nav_footer" id="nav_footer">Next Section: <A href="qs-Navigate.htm">Navigate to a Java element's declaration</A>
<img src="../images/ngrelc.png"  alt="Related concepts" border="0"> 
<p> <a href="../concepts/concept-java-views.htm">Java views</a><br>
  <a href="../concepts/concept-refactoring.htm">Refactoring support</a> </p>

<p> <img src="../images/ngrelr.png"  alt="Related reference" border="0"> 
<p> <a href="../reference/ref-menu-refactor.htm">Refactoring actions</a><br>
  <a href="../reference/ref-wizard-refactorings.htm">Refactoring wizard</a><br>
  <a href="../reference/preferences/ref-preferences-java.htm">Java preferences</a> </p>


New to GrepCode? Check out our FAQ X