Results 1 to 7 of 7
  1. #1
    wyldstyle is offline Member
    Join Date
    Feb 2009
    Posts
    11
    Rep Power
    0

    Default Running .java-files won't work/compile does!(Code inside)

    Hey there and sorry for the strange Topicname but i could not found any short description for my problem since i don't even know what kind of problem it is!

    I have downloaded the jdk6.12 from the sun homepage, installed it and set the path (i hope i did that correctly,using windows xp).

    To check out if everything is working correctly i tried to write a small Programm and run it and there lies the problem. Compiling any code will work without mistakes but i cannot run the code, it always gives me this message and i dont know what it does mean:

    Java Code:
    D:\Java>java ShortBsp.java
    Exception in thread "main" java.lang.NoClassDefFoundError: ShortBsp
    Caused by: java.lang.ClassNotFoundException: ShortBsp.java
            at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
            at java.security.AccessController.doPrivileged(Native Metho
            at java.net.URLClassLoader.findClass(URLClassLoader.java:18
            at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java
            at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java
    Could not find the main class: ShortBsp.java.  Program will exit.
    jdk is installed to c:\programm files\java\jdk...
    Java-Files are at D:\Java

    My steps to create a programm:
    open notepad, type the code and store it in the folder.
    cmd -> CD D:\Java
    javac ShortBsp.java
    java ShortBsp

    It would be really cool if somebody could tell me how to solve this problem! So far i have found a lot of threads of people who had a similar problem but i have yet not found a solution!


    Sys
    wyldstyle

  2. #2
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    9

    Default

    what does your class declaration in your code look like?

  3. #3
    wyldstyle is offline Member
    Join Date
    Feb 2009
    Posts
    11
    Rep Power
    0

    Default

    Java Code:
    class ShortBsp{
    
    public static void main (String[] args){
    
    int[] test = new int[8];
    System.out.println("Test:D");
    }
    }
    Its really strange, there is no error message if i try to compile, verything works and the compiler will create a .class file also! Dont wonder about the code...i know it makes no sense!
    Last edited by wyldstyle; 02-06-2009 at 06:17 PM.

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    10

    Default Running a Java program...

    D:\Java>java ShortBsp.java
    Some basics...
    • To compile: javac ShortBsp.java
    • To run: java ShortBsp (don't add the .java extention)


    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  5. #5
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    9

    Default

    nice, i didn't notice that. heh

  6. #6
    wyldstyle is offline Member
    Join Date
    Feb 2009
    Posts
    11
    Rep Power
    0

    Default

    Oh my god, sorry. I am such an idiot ;/.

  7. #7
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    10

    Default Hey... no problem

    Don't worry... It has happened to all of us when we were starting. I still forget to put the dang ";" sometimes...

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. Replies: 1
    Last Post: 01-16-2009, 11:14 AM
  2. Compile/Execute code in Java app
    By Doctor Cactus in forum New To Java
    Replies: 5
    Last Post: 12-16-2008, 10:58 AM
  3. Running batch files in java
    By pradeesh in forum New To Java
    Replies: 10
    Last Post: 12-04-2008, 10:26 PM
  4. auto-compile won't work on svn import
    By anacapa in forum Eclipse
    Replies: 0
    Last Post: 10-10-2008, 04:46 PM

Posting Permissions

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