Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Java on Ubuntu 11.10 ( Error )

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ..
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this






Regards,
Vijay
 
Marshal
Posts: 74367
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 74367
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 74367
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 74367
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic