Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Java runtime has stopped running

  1. #1
    Join Date
    Dec 2008
    Beans
    279
    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
    5,490
    Distro
    Xubuntu 14.04 Trusty Tahr

    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
    279
    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
    5,490
    Distro
    Xubuntu 14.04 Trusty Tahr

    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
    279
    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

  7. #7
    Join Date
    Dec 2008
    Beans
    279
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Java runtime has stopped running

    Thanks men, it looks like I was running both the openjdk and the sun-java6-jdk, I uninstalled both, then reinstalled sun-java6-bin/jdk and am now getting a slightly different error code:
    Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: TempTest
    Caused by: java.lang.ClassNotFoundException: TempTest
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    The error codes are different now, I'm trying to figure out what they mean.

  8. #8
    Join Date
    Jun 2007
    Beans
    290
    Distro
    Kubuntu 9.04 Jaunty Jackalope

    Re: Java runtime has stopped running

    Sorry, but there's nothing "wrong" with Java - that exception means exactly what it says: it cannot find a class. I would seriously recommend reading the Java tutorial about ClassPaths and the like - it's really quite essential for understanding how that aspect of Java works, especially if you're programming in it.

    FYI, using the CLASSPATH environment variable is usually not recommended any more - that kinda changed with Java 1.3
    E. A. (Ed) Graham, Jr.
    Linux User #28251
    Professional Java Geek

  9. #9
    Join Date
    Dec 2008
    Beans
    279
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Java runtime has stopped running

    @ crackers, while I appreciate what I suppose we could call an attempt to help, you clearly haven't read anything I said. I said I removed the classpath and that that might have been the cause of the problem, and I also said that since my programs ran fine under windows, there is obviously something "wrong" with my runtime and my system, not with java itself so don't get your feelings hurt. I obviously wouldn't use it if I thought something was wrong with it.

    Anyway, I still haven't figured out what's going on or found anyone else with a similar problem, I'm literally able to 'java helloWorld' in virtualbox and it runs just fine, then 'java helloWorld' in ubuntu on the exact same file and it gives me the class not found error
    Last edited by v1nsai; March 23rd, 2009 at 03:36 AM.

  10. #10
    Join Date
    Mar 2009
    Beans
    2

    Re: Java runtime has stopped running

    I'm having a similar problem, java won't run anything at all on my system after I used a CLASSPATH for something. Maybe I didn't change /etc/environment back to normal, what is the default? Mine currently only has
    /etc/environment:
    Code:
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

Page 1 of 2 12 LastLast

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
  •