how to compile & run the gedit 'xyz.java' after installing java?

Asked by Asif ansari on 2012-09-22

Hi sir, i have installed java runtime 7 via software center.After which i am stuck..how should i compile any of the text gedit file xyz.java and run it and the output?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu openjdk-7 Edit question
Assignee:
No assignee Edit question
Solved by:
Asif ansari
Solved:
2012-10-18
Last query:
2012-10-18
Last reply:
2012-09-22

Try:

java xyz.java

samuel (samuel-h) said : #2

If it is a .java file editable in gedit you will have to compile it first, for this use javac xyz.java, if javac doesn't work install the JDK. Then to execute it navigate using cd to the location the .class file genearated by javac xyz.java and type java xyz (the .class is not nesscary, however you must be in the location of the file), this will execute the program. If you are planning to develop java I would reccomend downloading eclipse or netbeans from the software center, as these provide syntax highlighting and will compile and run the program at the push of a button.

Asif ansari (asif-ansari4u) said : #3

asif@asif-desktop:/media/Softwares$ java QueueTest.java
Error: Could not find or load main class QueueTest.java

Asif ansari (asif-ansari4u) said : #4

though the program is compiled it is not running

Asif ansari (asif-ansari4u) said : #5

Thanks it helped......thanx alot