• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java on Ubuntu 11.10 ( Error )  RSS feed

 
Ahmad El-Komey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have installed JDK 7:

also, I have installed jre:


I opened my text editor ( Geany ) and created a new file, named it "test.java" and started to salute the world:

I saved the file on the desktop, so:


and now here is the result:


any help?
thanks in advance ..
 
Vijay Kalkundri
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this






Regards,
Vijay
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, both of you

I would suggest the desktop is not a good place to keep programs. Least of all if you use Unity with those big icons! I think there is a better place to put your work, as I suggested here.
 
Ahmad El-Komey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Vijay Kalkundri: I did try that too. Still the same error shows up

@ Campbell Ritchie: Thanks for the greeting

I have uninstalled both JDK7 and JRE7:



and re-installed them, but nothing happened .. the same error shows up

one of my friends suggested to install netbeans and things will turn to be OK. And for my surprise, he was right!!
I still don't know what happened in the underlying OS, and that means I need to read more and more about linux and Ubuntu.

Thanks guys for your concern
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahmad El-Komey wrote:@ Vijay Kalkundri: I did try that too. Still the same error shows up


No, it can't be the same error.

The next step would be to try this:


one of my friends suggested to install netbeans and things will turn to be OK. And for my surprise, he was right!!


The only way that could have made a difference in the above suggested command is if the installation set your CLASSPATH environment variable to include . ("dot", the pwd).

Note that you shouldn't rely on the CLASSPATH env var, but instead should specify the classpath on the command line.
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is worth trying the following instructions at a terminal (root or sudo access not required):If you get no response to the which instructions, you will have to search for the java tool. you should see what the PATH points to, and it is best to have an empty system CLASSPATH.
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahmad El-Komey wrote: . . . one of my friends suggested to install netbeans . . .
That is not usually good advice. Learning NetBeans is difficult and may distract you from learning Java™.
 
Ahmad El-Komey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:It is worth trying the following instructions at a terminal (root or sudo access not required):If you get no response to the which instructions, you will have to search for the java tool. You should see what the PATH points to, and it is best to have an empty system CLASSPATH.


here's the output - after netbeans installation -

the last echo command has no output.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahmad El-Komey wrote:
I saved the file on the desktop, so:


and now here is the result:
...

You get that error because to run the program, you must pass the class name, which is test, not the filename test.class to the java command.

So it must be: java test
and not: java test.class
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That PATH and the results of the which instructions suggest you are using the Java™ installation which comes with Ubuntu. If you look in our FAQ, it explains about OpenJDK and the Sun/Oracle version. I don’t know how to use apt to install the Sun/Oracle JDK7, but you can use the instructions here. If you do that, remember you will need to set a PATH, as desribed in that FAQ I showed you.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!