Listing is powerful tool , more documentation can be found here:The Listings Package.
Instead of setting global settings you should set styles for each individual listings
Flowing code should give you good picture of how to customise listings.
\documentclass{article}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{xcolor}
\lstdefinestyle{basic}{
basicstyle=\footnotesize\ttfamily,
numbers=left,
numberstyle=\tiny\color{gray}\ttfamily,
numbersep=5pt,
backgroundcolor=\color{white},
showspaces=false,
showstringspaces=false,
showtabs=false,
frame=single,
rulecolor=\color{black},
captionpos=b,
keywordstyle=\color{blue}\bf,
commentstyle=\color{gray},
stringstyle=\color{green},
keywordstyle={[2]\color{red}\bf},
}
\lstdefinelanguage{custom}
{
morekeywords={public, void},
sensitive=false,
morecomment=[l]{//},
morecomment=[s]{/*}{*/},
morestring=[b]",
}
\begin{document}
\lstinputlisting[ style=basic, language=Python]{main.java}
\lstinputlisting[ style=basic, language=Java]{main.java}
\lstinputlisting[ style=basic, language=custom]{main.java}
\end{document}
Three version of customised listings presented in the code above
they all use same colours for identity of: strings, comments, keywords.
also I showed how to create new language for your need. you can use existed languages for your foundation and add more keywords to it.
[UPDATE]
Here is set of different styles , I personally prefer this one.
\documentclass{article}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{color}
\usepackage{accsupp}
\definecolor{dkblue}{rgb}{0,0,0.5}
\definecolor{comment}{rgb}{1,0,0}
\definecolor{mauve}{rgb}{.627,.126,.941}
\definecolor{purple}{rgb}{0.5, 0, 0.545098}
\lstdefinestyle{java}{
belowcaptionskip=1\baselineskip,
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
breaklines=true, % sets automatic line breaking
xleftmargin=\parindent,
language=Java,
tabsize=4,
tabsize=4,
numbers=left,
showstringspaces=false,
numberstyle=\tiny\noncopynumber,
basicstyle=\footnotesize\ttfamily,
keywordstyle=\bfseries\color[rgb]{.133,.545,.133},
commentstyle=\itshape\color{blue},
stringstyle=\color{mauve},
directivestyle=\bfseries\color{purple},
frame=single],
resetmargins=true,
}
\lstdefinestyle{mathlab}{
belowcaptionskip=1\baselineskip,
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
breaklines=true, % sets automatic line breaking
xleftmargin=\parindent,
language=C,
morekeywords={end, elseif},
comment=[l]\%, % comments
tabsize=4,
numberstyle=\tiny\noncopynumber,
showstringspaces=false,
basicstyle=\footnotesize\ttfamily,
keywordstyle=\color[rgb]{0,0,1},
commentstyle=\itshape\color[rgb]{.133,.545,.133},
stringstyle=\color{mauve},
directivestyle=\bfseries\color{purple},
framexleftmargin=3mm,
frame=single,
}
\newcommand{\noncopynumber}[1]{%
\BeginAccSupp{method=escape,ActualText={}}%
#1%
\EndAccSupp{}%
}
\begin{document}
\lstinputlisting[caption=Matlab style main code: "main.java", style=mathlab]{main.java}
\lstinputlisting[caption=Matlab style main code: "main.java", style=java]{main.java}
\end{document}
Best Answer
Here's the idea:
I used UTF-8 and I recommend you do too (change how your text editor saves files, of course; but it should work also with the ISO 8859-7 encoding).
Here's the page with Greek:
and here's the page with English: