# Copy javacode to laTex

I am new to latex and I wonder if I can copy some java code to my latex document, and use some kind of package or something where I can specify that from "here" to "here" I have javacode and I would like it to show linenumbers, syntax with colors and stuff

Thanks

-

You can use the listings package. Some usage information can be found on Wikibooks:

Using the package listings you can add non-formatted text as you would do with \begin{verbatim} but its main aim is to include the source code of any programming language within your document. It supports highlighting of all the most common languages and it is highly customizable. If you just want to write code within your document the package provides the lstlisting environment:

\begin{lstlisting}

\lstinputlisting{source_filename.py}

\lstinputlisting[language=Python]{source_filename.py}