You can enter code into SQL Developer by typing it in, copying and pasting from an external source file or choosing File - Open from the menu. Make sure to set the option to display line numbers to ease the interpretation of error messages and subsequent debugging. You can right click in the line gutter and choose "Toggle Line Numbers" as shown below. If you want line numbers to persist between invocations of SQL Developer, then click on the "Tools" menu and select "Preferences", "Code Editor", "Line Gutter" and click the "Show Line Numbers" checkbox.
If you are typing code in or copying and pasting, you can open a database connection by choosing to do so from the list of configured connections from the Connections tab on the left. However, if you open an existing file, you will need to choose a database connection to use. If a connection is not selected, the ability to execute scripts is disabled. This is because PL/SQL actually executes within the database itself.
As mentioned earlier, by default the "DBMS_OUTPUT" tab is not open in SQL Developer. To show the server output, select View and Dbms_Output.
Once a database connection has been selected, the user interface will reflect the ability to run scripts.
If the DBMS_OUTPUT package is in use, code can be executed but no results will be displayed until serveroutput is set to on.
This can be done by running the command or by selecting an appropriate menu option. If you type in the command in SQL Developer then the server output will be displayed in the "Dbms Output" tab. In addition the output and any system messages will be displayed in the "Script Output" tab. You can see these two behaviors in the screen shot below.
If you want to separate the display of system messages from program output, then do not type the SET SERVEROUTPUT ON command. Instead, as indicated in the next screen shot, click the plus sign on the "Dbms Output" tab. Then select the appropriate connection from the "Connection" drop down list and click ok. This essentially performs the same process as the SET SERVEROUTPUT ON command but limits the display to just the "Dbms Output" tab. Notice the "Dbms Output" tab includes a number of additional controls relating to the display of server output from your program.
The next screen shot illustrates the separation of the script output from the dbms output when you perform the steps in the above screen shot instead of executing the "set serveroutput on" statement in SQL Developer.