Vim - When I run my Java file, the println statements don't seem to be getting executed -
i'm using gvim. created file caled insertionsort.java , inside file:
public class insertionsort { public static void main (string[] args) { system.out.println("hello world"); } }
i opened terminal , did
sudo apt-get install default-jdk
to install javac. next, went gvim , did:
:!javac %
to run current file. when did this, said:
!javac /documents/java/insertionsort.java press enter or type command continue
and when press enter, goes insertionsort.java. doesn't print anything. looked @ post: compiling java code in vim more efficiently , highest rated answer said add these .vimrc file:
autocmd filetype java set makeprg=javac\ % set errorformat=%a%f:%l:\ %m,%-z%p^,%-c%.%# map <f9> :make<return>:copen<return> map <f10> :cprevious<return> map <f11> :cnext<return>
after adding above lines .vimrc file, reopend gvim / insertionsort.java , pressed f9 , said:
!javac documents/java/insertionsort.java 2>&1| tee /tmp/vcqce1x/8 :copen press enter or type command continue
and when pressed enter, opened new gvim file called:
[quickfix list] :javac documents/java/insertionsort.java
and file did not have in (it didn't "hello world"). how make run file displays "hello world"?
i think may mixing java
, javac
programs. javac
compiles *.java
source files *.class
bytecode files. java
takes compiled *.class
bytecode files , runs them. if goal compile , run file called example.java
, you'll need this:
javac example.java java example
Comments
Post a Comment