My first Java program does;'t work HELP

I received the following message in the Command Prompt:Exception in thread "main" java.land.NoClassDefFoundError: Test
How do I fix this?
Source Code:
import java.awt.MediaTracker;
class Test {
public static void main(String[] args) {
for (int i = 0; i < args.length; i++)
System.out.print(i == 0 ? args[i] : " " + args);
System.out.println();

You might want to make your class public, although I don't think that's supposed to be necessary. It's most likely a classpath issue.
Instead of java Test, try java -cp . Test (Note the dot between -cp and Test.)
Javapedia: Classpath
How Classes are Found
Setting the class path (Windows)
Setting the class path (Solaris/Linux)
Understanding the Java ClassLoader
java -cp .;<any other directories or jars> YourClassNameYou get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
javac -classpath .;<any additional jar files or directories> YourClassName.javaYou get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

Similar Messages

  • My java programe does not work

    Hi
    I createda java programme with jdeveloper . I compiled my code in all of version (1.3, 1.4, 1.5, 1.6 and default).
    But when i try to run my programme in other computers that have j2SE Runtime Environment 5.0 update 11, or java Runtime 2 Environment SE 1.3 - 1.4,
    my programme doesnot work.
    how can i fix this problem.

    Which Jdev version?
    What exactly do you mean by 'does not work'?
    Timo

  • I just signed up for a subscription to adobe reader paying EUR 24.40. The program does not work, and I can not even go to my personal page .... help ...?

    I just signed up for a subscription to adobe reader paying EUR 24.40.
    The program does not work, and I can not even go to my personal page .... help ...?

    Adobe Reader is free; it does not require a subscription.
    Did you subscribe to an online service like ExportPDF, PDF Pack, ...?
    What exactly does "not work" mean?

  • Hello Since yesterday evening. My itunse program does not work my mobile. Note  I update the program to ios7 Please help me Thank you

    hi
    Hello
    Since yesterday evening. My itunse program does not work my mobile.
    Note
    I update the program to ios7
    Please help me
    Thank you

    I found this strange glitch that wouldn't let me open my iTunes Store. I tried all the reset options and still iTunes would close a second after it opened. I fixed this. Instead of using the iTunes Store icon on your home page to open it. Go into music and click on store. It will say "Cannot Connect To Store". Just tap ok. Then tap on "featured" on the bottom of the screen. That will take you to the store front page. After that is loaded. Back out and the icon for iTunes Store on the home page should work just fine. Hope that helps.

  • Java program in XP - Please Help

    Hi, I am not sure if I am in the right fourm. I am not a developer, but a network engineer trying to help out my wife. My wife uses a java program to monitor the company she works for web site, which is not linked to a web browser. When she received the java program, it came with Java 1.2.2. Our PC had Windows 98 installed. I purchased a new machine, with Windows XP on it, and installed the java program and JRE on to it. The program does not work. The programmer who wrote the program was fired a few months ago, so I started looking through the internet, and the Sun fourms for a solution. First, the XP machine does not have Microsoft VM on it. Second, I upgraded the java to 1.4.1_02, following the instructions, still with no success. There was a suggestion to dual boot with Windows 98, but I really do not want to do that. What happens is - when you log in to the program, it just freezes. It does not go into the server. Any help is greatly appreciated.

    Possible reasons for the program hanging up
    1) The version of the VM on the machine is not correct.
    2) Even if the version is correct and correctly installed, can you please check whether the PATH and CLASSPATH variables are set correctly on the machine where you are running the program.
    3) I use WINXP as well with the latest version of VM downloaded from Sun and NOT Microsoft.
    Hopefully this might solve the issue.

  • TS1702 Maps program does not work. In standard it only shows a grid. If I ask for a route it shows start and end point and three route boxes but nothing else. It does show directions. If I switch to hybrid it shows to routes but no roads. Background is a

    Maps program does not work. In standard it only shows a grid. If I ask for a route it shows start and end point and three route boxes but nothing else. It does show directions. If I switch to hybrid it shows to routes but no roads. Background is a blur.

    Do you have a question? This is a user to user help forum. Apple is not here only other users like yourself. You don't report problems to Apple here.
    By the way, it might help if you indicated where you are located.
    To complain to Apple use http://www.apple.com/feedback/ipad.html

  • Every time I try to open Photoshop Elements 12, it opens the Adobe login, after I login the program does not open:( Help please?

    Every time I try to open Photoshop Elements 12, it opens the Adobe login, after I login the program does not open:( Help please?

    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    You can use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    You have to close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")

  • Now a few of programs does not work with mountian lion. what to do?

    now a few of programs does not work with mountian lion. what to do?

    espons printer/scanner, toast titanum 5.2.1, intuos 4 wacom, appleworks, already updated ms office & order the upgrade for reunion which I hope it will work. 
    thank you mr michael allbritton for your help!

  • My first java program!! ALMOST done..I hope

    I've just written my first java program (part of a class I'm taking).. It's feeling kinda awkward since I'm a C++ programmer.. I've written most of the code but I'm still having problems and I thought I should show it to you to get some help..
    import java.lang.*;
    import java.util.*;
    public class Dice
    private static Random generator = new Random();
    int Die1, Die2, rolled, pairNum, pairSum;
    public Dice()
       int[] Dice_arr={Die1, Die2};
       new Random(System.currentTimeMillis());
       return;
      }//end_func_Dice
       public static roll()
         rolled = generator.nextInt(6) + 1;
         return rolled;
        }//end_func_roll
       public String toString()
         StringBuffer bfr = new StringBuffer("\n");
         System.out.println("Rolling Dice...");
          for(pairNum=0; pairNum==10; pairNum++)
            System.out.println("Pair"+pairNum+": "+Die1+","+Die2+" Sum= "+pairSum);
           }//end_for_
        }//end_func_ 
    }//end_class_Dice
    public static void main(String args[])
          for (int dieNum=0; dieNum==2; dieNum++)
            Dice.roll();
            Dice_arr[dieNum]=rolled;
           }//end_for_
         return;
        }//end_func_mainI need main to instatiate the Dice class and then use the toString to print the dice numbers and their sum 10 times..
    I hope this doesn't need much effort,
    Thanks a bunch in advance..

    Right now, my opinion in java is that it's too
    complicated for no reason compared to C++..It's not too complicated, it's just that you are new at this.
    Here's a little example of a simple class with a simple main method, the rest figure it out yourself, and with time read some java books, you won't learn java just by knowing C++.
    public class Human {
        // See this as C constants (although they're not their Equivalent)
        public static boolean MALE = true;
        public static boolean FEMALE = false;
        //member variables.
        private String name;
        private boolean sex;
        /** Creates a new instance of Human */
        public Human(String n, boolean s) {
            name = n;
            sex = s;
        }//End of CONSTRUCTOR.
        public String getName() {
            return name;
        }//End of getName
        public String toString() {
            StringBuilder sb = new StringBuilder();
            sb.append("[Name: " + name);
            if(sex)
                sb.append(", sex: Male]");
            else
                sb.append(",sex: Female]");
            String returnValue = new String(sb);
            return returnValue;
        }//End of toString()
        //Just the main program, it could be at another class.
        public static void main(String[] args) {
            Human h = new Human("Pablo", Human.MALE);
            String theHumanAsAString = h.toString();
            System.out.println(theHumanAsAString);
        }//End of main method
    }//End of class

  • Trying to compile my first Java program !

    Hi,
    I am a new programmer.Looking to clarify a very simple doubt while compiling my first java program.
    I have set up jdk in the following directory on my PC , E:\j2sdk1.4.1_01\bin.
    Now when I create the first AClass.java file in the AClass directory under bin and try and compile it I get the following error.
    E:\j2sdk1.4.1_01\bin>java E:\j2sdk1.4.1_01\bin\AClass\AClass
    Exception in thread main
    java.lang.NoClassDefFoundError: E:\j2sdk1/4/1_01\bin\AClass\AClass
    Kindly help me how to fix this.

    hi,
    Just do this,
    set path & classpath either in the system environment veriable or in the command prompt as shown below.
    set PATH=%PATH%;E:\j2sdk1.4.1_01\bin
    set CLASSPATH=%CLASSPATH%;.
    Be careful, there is a trailing DOT (.) at the end of the classpath, and that is what needed for
    the JVM to find the class file. with this you would be able to run your program. Infact JDK1.4.x and higher
    doesn't requires classpath to be set, your system classpath variable needs a DOT (.)
    at the end of the classpath variable defined in the environment variable section of your computer or
    in the command prompt you need it to set it once for the current command prompt window before
    executing any java program.
    Regards
    Goodieguy

  • Clicking the lock does not work HELP

    clicking the lock at any kind of program does not work at all, not working in system pref,
    not working at ''get info'' window, not working in any other kind of lock, i tried defragging via idefrag but that couldn't work because it needed a lock to be opened as well, i can't move my files to some folders, getting the ''The operation can’t be completed because an unexpected error occurred (error code 100022).''
    plus when i log out, cannot log in because when i type my password it accepts it but then nothing happens, i had a root account as well but i can't enter it and can't create again because of the lock, but when i log in with guest account(no pass required) i can make changes via clicking the lock and filling in admin username and password in system preferences. and i created a new admin account in guest account by filling admin info for authorization in system preferences > users&groups , set no password, logged out but could not log into that account as well. my system is set to login to my account when the system starts. so thats how i can use the computer

    Back up all data if you haven’t already done so. There are ways to back up, even if you can’t log in. Before proceeding, you must be sure you can restore everything to the state it’s in now. If you’re not sure you can do that, STOP.
    Briefly, you need to delete the following file:
    /var/audit/current
    If you already know how to do that, you can skip the rest of this message. Do it, and try again to log in.
    Step 1
    Boot in single-user mode by holding down the key combination command-S at the startup chime. If you’re using an external USB keyboard, it must be plugged directly into a built-in port on the Mac, not into a hub. Release the keys when you see a black screen with scrolling white text. In this mode, there’s no graphical interface; just a command line. Initially, you can’t make any changes to files.
    Step 2
    When the text stops scrolling, and you see a line ending in a pound sign (“#”), type the following command:
    rm /var/audit/current
    You must type the command exactly as given. If you don’t feel able to do that, STOP. At this stage, no harm will be done if you make a mistake, but later, it will be.
    Press the return key. You’ll get an error message about a “read-only filesystem” below what you entered. There must be no other error message. If there is, try again until you get it right. You’ll continue to get the read-only error.
    You might get the error “No such file or directory,” even if you entered the command correctly. If you’re sure that’s the case, stop and post again.
    Step 3
    Once you’ve taken steps 2, and received the expected error messages, enter the following command:
    mount -uw /
    Again, you must get it exactly right. This time, there should be no output at all. If there is, you mistyped the command, or something else is wrong.
    Step 4
    When you’ve taken step 3 with no error message, press the up-arrow key until the command from step 2 (rm …) reappears. If you got everything right on the first try, you’ll need to press the key twice. Make sure the command is correct, then press return again. There should be no output. If there is any, make a note of it and post a reply.
    Step 5
    Enter the command:
    exit
    Press return. The text will start scrolling again, and then the system will reboot. Try again to log in.
    Credit for this solution is due to ASC user AnthonyTW.

  • Java program code paper work

    Where to find industrial standards for Java program code paper work (indents, large or small characters, brackets position on page, capital letters for constants etc.)?

    Usually, this will depend where you're working. Each has its own standards , but here's Sun's coding standards:
    http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html

  • I purchased a program on Mac App store and the program does not act as it should,  also was required to pay up front whereas had I went to the web site, ibank 4 I would have had 30 days free trial an would have found that the program does not work.?

    I purchased a program on Mac App store and the program does not act as it should,  also was required to pay up front whereas had I went to the web site, ibank 4 I would have had 30 days free trial an would have found that the program does not work.?

    Free trials are not available through the Mac App Store.
    Apple is not here. Apple does not answer questions here. This is a user to user support forum. There are only folks here who use Apple products.

  • My program does not work properly. I run the program but it is not capable of adding any of my ebooks and when I connect my ereader, it recognises the device but  it does not add any ebook either.  I uninstalled the program and reinstalled again but nothi

    my program does not work properly. I run the program but it is not capable of adding any of my ebooks and when I connect my ereader, it recognises the device but  it does not add any ebook either.
    I uninstalled the program and reinstalled again but nothing gone better-
    What should I do?
    Best regards

    Do you have Logitech gaming software installed on the PC? If so, perhaps try the suggestion from the following post:
    Re: Everytime I close Itunes it loads back up

  • On my iPhone 5 camera photographed not clear. blurry pictures, autofocus does not work. help please!

    on my iPhone 5 camera photographed not clear. blurry pictures, autofocus does not work. help please!

    Could you please describe how you are trying to delete a single text message and it will not work? What are you seeing in place of the trash can icon?

Maybe you are looking for

  • Oracle 8.1.7 on Redhat linux 7.3

    I know that on Linux 7.1 there was a patch (p2062423) to get the installation going but I can not seem to find the patch for linux 7.3 Please help

  • Why am I getting an error when I sync my iPhone 5S?

    The error message "The iPhone "iPhone name" cannot be synced.  An unknown error occurred (-54)." came up when I have been syncing my new iPhone 5S. This didn't start happening until last night, when I restored my iPhone from an old back-up I had from

  • Upload interactive form and access field values in WD component

    Hi Experts, I want to upload a prefilled  interactive adobe form in my webdynpro component and then I want to read the values filled in the form in my webdynpro component. I don't want to display the interactive form in the WD component. Just need to

  • PP Process Order Status Get

    Hi all, I want to have the Correct Process Order Status in PP Module. i got one function : CBIF_GLM1_PROCESS_ORDER_READ :but it shows all Status, i just want Active Status. The Status who are checked, i want only them. thanks, Usman Malik

  • Sorting by Keyword -then lost sort menu and captions under some pics

    I finally sorted all my photos by keyword- very handy. But when I opened up iPhoto again, some appeared without keywords, although I know I either had trashed some or keyworded them previously. Then when I tried to open the "sort by" menu to re-do th