Results 1 to 10 of 12

Thread: Java runtime has stopped running

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Beans
    280
    Distro
    Ubuntu 9.10 Karmic Koala

    Java runtime has stopped running

    I'm having trouble running java programs on my ubuntu box. I was coding something for my java class, and became suspicious when my programs kept returning this when I ran 'java nameOfProgram':
    Code:
    Caused by: java.lang.ClassNotFoundException: TempTest
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
    Could not find the main class: TempTest. Program will exit.
    I get the same error when I run examples from the book. They all have main methods, which is what the error seems to be complaining about. Everything runs fine on Windows XP in virtualbox.

    So, first of all what the hell? Why did this happen? I've been running java on my computer no problem for a while now. And second, what can I do to fix this? I've already tried 'sudo apt-get remove sun-java6-jre sun-java6-jdk' and 'sudo apt-get install sun-java6-jre sun-java6-jdk' but still the same problems. I can compile with no hitch, it just seems to be the runtime. Help appreciated, I'm stumped.
    Last edited by v1nsai; March 21st, 2009 at 10:41 PM.

  2. #2
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    6,175
    Distro
    Xubuntu

    Re: Java runtime has stopped running

    Make sure your command prompt is running in the same directory as the class file you compiled. The command ls should show TempTest.class amongst others.

  3. #3
    Join Date
    Dec 2008
    Beans
    280
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Java runtime has stopped running

    You know, I almost got really pissed off that you were actually reminding me to cd into the correct folder, but I tried 'java TempTest' in the wrong folder, and still got the same response so I guess your not calling me a space cadet lol. I'm still getting the error whether or not I'm in the correct folder, I'm compiling without error then running java too.

    Anyway, it's acting like it doesn't see the class file, that's weird. I ran 'java -version' and it returned that its java build 1.6.0_0-b11, so as far as I can tell the jre is up and running.
    Last edited by v1nsai; March 22nd, 2009 at 05:09 AM.

  4. #4
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    6,175
    Distro
    Xubuntu

    Re: Java runtime has stopped running

    No offence was intended. I've done it myself. The only other things I can think of are:

    That somehow your CLASSPATH environment variable is preventing you from seeing local class files, though I don't know how that might happen. Try making sure you do NOT have a CALSSPATH environment variable.

    Or the class source has a package declaration in it, such that it shoud really live in a subdirectory. Actually, I just tried this and it gives the error message you are seeing. So it a class is declared as "package brownenvelope;" for instance, it needs to be in brownenvelope/TempTest.class and launched as "java brownenvelope.TempTest".

  5. #5
    Join Date
    Dec 2008
    Beans
    280
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Java runtime has stopped running

    I did add a classpath recently (I was playing around trying to cross compile java on the iphone) and got rid of it via gedit /etc/environment but I'm still getting the same error. Do I need to restart anything to get the changes to register? My /etc/environment file now contains only
    Code:
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
    It's definitely not in a package or anything like that, I used BlueJ to write it but I've always used bluej and never had problems running from shell.

  6. #6
    Join Date
    Sep 2008
    Location
    Israel
    Beans
    53
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Java runtime has stopped running

    There are number of java versions. They can be installed simultaneously.
    Errors like these you posted it seems caused if used open source version of java.
    Java from Sun is most reliable.

    In order to see which javas you have type in Terminal:
    Code:
    update-java-alternatives -l
    In order to install Sun's java type:
    Code:
    sudo apt-get install sun-java6-bin sun-java6-jdk
    In order to activate Sun's java type:
    Code:
    sudo update-java-alternatives -s java-6-sun

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •