Java not running .class files

I rebooted my computer, and now whenever I type
java <filename> it responds with:
C:\Development\Java\Projects\Scratch>java T1
Exception in thread "main" java.lang.NoClassDefFoundError: T1
However, it compiles fine:
class foo {
class T1 {
    public static void main (String [] args) {
        foo [] fooArray = new foo[5];
        if (fooArray[1] instanceof Object)
          System.out.println("fooArray[1] is an object");
        if (fooArray[1] instanceof foo)
          System.out.println("fooArray[1] is a foo");
}What am I missing to get it to run with java T1?
(every other class file that used to work behaves the same way)

Yes, it is the classpath. Strangely . is in my classpath in the environment settings in the control panel. I guess I can survive adding -cp . but it is kind of a pain in the a__ for no reason I can discern

Similar Messages

  • Java not creating .class file ?

    I copied and pasted text into textpad then saved textpad creats the java file but no class file ! What gives ? I tried rebooting , the class name is the same (not mispelled) even did a HD search for class file and its no where to be found

    You have to compile a Java source file into a class file.
    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html

  • Running class files from the windows command line...

    Hello Everyone,
    My instructor showed us a way to run class files from the windows command line. However every time I try to run the class file from the command line using a command like: java CruiseHelper.class
    I get an error that states "Exception in thread "main" java.lang.NoClassDefFoundError: CruiseHelper/class"

    Hello Everyone,
    My instructor showed us a way to run class files from
    the windows command line. However every time I try
    to run the class file from the command line using a
    command like: java CruiseHelper.class
    I get an error that states "Exception in thread
    "main" java.lang.NoClassDefFoundError:
    CruiseHelper/class"Classes are not file names. You don't have a class named "CruiseHelper.class", that's a file name. The class name is just CruiseHelper (if you have no package statement in it).
    So,
    java -classpath . CruiseHelper

  • J2se java not running

    I keep getting an "Exception in thread "main" java.lang.NoClassDefFoundError: CalendarTest"
    I am getting this type of error for each time I run any of the files that "I am able to compile it", just not run it.
    I am running XP os. I have run the same programs on a different computer and os and they work fine.
    I have gone through and tried most of the suggestion, but have not come up with a working solution.

    My First Java Program (for Windows)
    Follow these steps:
    1. Download and install the Java 2 SDK
    2. Make sure your path and classpath are set correctly
    3. Type in your first program
    4. Compile your first program
    5. Run your first program
    6. Read the Java tutorial
    1. Download and install the Java 2 SDK
    Go to the Java website and download the Java 2 SDK, Standard Edition:
    http://java.sun.com/j2se/1.4.1/download.html
    NOTE: Make sure you download the SDK (leftmost column) and not just the JRE. The JRE (Java Runtime Environment) only contains the stuff necessary to run Java programs, and not the compiler and other tools you need to develop Java programs.
    After downloading, run the installation program to install the Java 2 SDK.
    2. Make sure your path and classpath are set correctly
    After installing, READ THE INSTALLATION NOTES! Lots of people get in trouble and are asking questions in the forums because they were too lazy to read and follow the installation notes. Especially, after installing the Java 2 SDK you need to add the 'bin' directory of the SDK to your PATH, otherwise you will get an error like "javac is not recognized as an internal or external command" or something similar.
    If you've installed the Java 2 SDK in C:\j2sdk1.4.1_03, add C:\j2sdk1.4.1_03\bin to the PATH. How you should do this for different versions of Windows is described in the installation notes: http://java.sun.com/j2se/1.4.1/install-windows.html
    If you are using a version of the Java 2 SDK older than 1.4, you need to add the current directory (".") to the CLASSPATH environment variable. CLASSPATH is where Java looks for *.class files (compiled Java classes). Since Java 1.4, Java looks in the current directory automatically if the CLASSPATH isn't set, so you don't need to add "." to the CLASSPATH. Again, the installation notes explain what CLASSPATH is and how you should set it.
    3. Type in your first program
    Start Notepad and type in your first program:
    public class HelloWorld {
        public static void main(String[] args) {
            System.out.println("Hello World");
    }NOTE: Java is case-sensitive. Be careful to type in the program exactly as shown above. Don't type "Helloworld" or "helloworld" or anything else.
    Save the file somewhere in a file called "HelloWorld.java". NOTE: Again, the case must be correct. Even though Windows is case-insensitive for filenames, the case must be correct, because Java is case-sensitive. Also watch out that Notepad doesn't append ".txt" to the filename (so that you end up with a file called "HelloWorld.java.txt"). To make things worse, Windows Explorer hides file extensions by default so you don't even see that the file is actually called "HelloWorld.java.txt" instead of "HelloWorld.java".
    4. Compile your first program
    Open a command prompt, CD to the directory that contains your source file and type:
    javac HelloWorld.java
    NOTE: Again, the case must be exactly right.
    If all goes well, you'll not get any error messages and a file "HelloWorld.class" is generated.
    5. Run your first program
    To run your program, type:
    java HelloWorld
    NOTE: Don't type "HelloWorld.class". You are specifying the class name here, not the filename. Ofcourse, the case is important again.
    6. Read the Java tutorial
    Go to the Java website and follow The Java Tutorial:
    http://java.sun.com/docs/books/tutorial/
    The chapter "Your First Cup of Java" also explains in detail how to start with Java.
    Jesper

  • Win xp not opening class file.

    win xp not opening class file.
    Runtime.getRuntime().exec("cmd /C start c:/database/Myclass.class");
    or
    Runtime.getRuntime().exec("cmd /C c:/database/Myclass.class");
    is this code wrong for xp ?

    let me give some more information...
    i have c:\database
    in this folder i have 2 class...Myclass.class and Dbconnection.class
    Myclass simply uses the database connection from Dbconnection.class , nothing else.
    you see both of the classes are in the same folder(i.e c:\database) and there is no package
    statement inside the code .
    in command prompt if i do....
    c:\database\java Myclass // this works fine
    but i want this class to run at runtime, so i did like above and it is not running!!
    what i am getting is a irritating windows file chooser is poping up and saying "class not
    found...browse or search in web...etc etc"
    Now my question is >
    Q1 . how can i run that class at runtime ?
    N.B
    here is some brief idea abt classes
    Dbconnection.java
    DriverManager.forClass("...database....");
    // only for database connection
    Myclass.java
    Connection con =db.getConnection();
    //use this con and show results for ur database related queries.
    }Q2. Can u plz tell those correct syntax how to run class file in this situation ?
    i will try all possible solutions tomorrow.
    thanx.

  • Tomcat6 does not load class files from WEB-INF/lib/myjarfile.jar  WHY???

    I have placed my jar file in c:\tomcat6\webapps\my-application\WEB-INF\lib\myjarfile.jar
    But, after restarting tomcat6, when i try to import the class file contained in the myjarfile.jar in a servlet, it says
    ProcessFileUpload.java:4: package test.test1 does not exist
    import test.test1.*;
    ^It clearly tomcat's class loading problem.
    As i unzipped my jar and placed the packagefolder structure to
    c:\tomcat6\webapps\my-application\WEB-INF\classes\testand it works perfectly.
    Anyone knows its workaround? please suggest if any configuration changes is required in tomcat or so.
    Thanks.
    ---Sujoy

    Thank you gimbal2 . There was error in creating the jar file myjarfile.jar.
    But, now I have created it again and placed it in place
    c:\tomcat6\webapps\my-application\WEB-INF\lib\myjarfile.jarand tried to use one on the Class file included within the jar to compile my servlet. But, still I am getting error at servlet compilation time. I want to place executable jar files in
    c:\tomcat6\webapps\my-application\WEB-INF\lib\myjarfile.jar and compile my servlet and execute the servlet.
    I DO NOT WANT TO unzip the jar, placing all unzipped files to
    c:\tomcat6\webapps\my-application\WEB-INF\classes\ folder and comiple my servlet and execute the servlet. But, I am failing to user WEB-INF\lib\ folder facility....please help me why i am not getting class files from WEB-INF\lib\ folder.
    If you please see the small code bit and tell me any possible error that would be very helpful.
    Step 1: my library java file MyClass.java
    package test.test1;
    public class MyClass {
         String myName = "Default return string value";
         public void setMyName(String varName) {
              this.myName = varName;
         public String getMyName() {
              return this.myName;
    }Step2 : Creating jar file of my library class files
    C:\jdk1.6\bin>jar cvf myjarfile.jar test
    added manifest
    adding: test/(in = 0) (out= 0)(stored 0%)
    adding: test/test1/(in = 0) (out= 0)(stored 0%)
    adding: test/test1/MyClass.class(in = 452) (out= 296)(deflated 34%)
    adding: test/test1/MyClass.java(in = 230) (out= 140)(deflated 39%)
    C:\jdk1.6\bin>Step3 : Double checking the created jar file content by listing its content
    C:\jdk1.6\bin>jar tf myjarfile.jar
    META-INF/
    META-INF/MANIFEST.MF
    test/
    test/test1/
    test/test1/MyClass.class
    test/test1/MyClass.java
    C:\jdk1.6\bin>Step4 : Placed myjarfile.jar to
    c:\tomcat6\webapps\my-application\WEB-INF\lib\Step5 : Restarted standalone Tomcat6 in my Windows XP SP2.
    Step6 : Created a simple servlet LibFolderTest.java within my-application\WEB-INF\classes\ folder with code
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import test.test1.*;
    public class LibFolderTest extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              MyClass mc = new MyClass();
              out.println(mc.getMyName());
    }Step7 : Tried to compile my servlet LibFolderTest.java and got the following error
    LibFolderTest.java:4: package test.test1 does not exist
    import test.test1.*;
    ^
    LibFolderTest.java:11: cannot find symbol
    symbol  : class MyClass
    location: class LibFolderTest
                    MyClass mc = new MyClass();
                    ^
    LibFolderTest.java:11: cannot find symbol
    symbol  : class MyClass
    location: class LibFolderTest
                    MyClass mc = new MyClass();
                                     ^
    3 errorsThe above servlet compilation error on Step7 is telling me that myjarfile.jar is not loaded by Tomcat6 or not available for use when compiling servlet. I want to use myjarfile.jar from within WEB-INF\lib\ folder but I can not. please help.
    ---Sujoy

  • How to run .class file and .jar file in jdev9i

    I want to run .class file and .jar file in jdev9i,what should I do?
    Also,I want to generate .class file and .jar file in jdev9i,what should i do?

    Add the .class file containing the public static void main(...) method to the project by clicking on the + toolbar button in the navigator, open the project properties and properly set the additional classpath then right click on the .class in the navigator and say run. It should work, I've just tried it.
    Doesn't work for a .jar yet, in JDeveloper 9.0.3 it works both for .class and .jar
    Michel

  • Running .CLASS file in Java JDK1.3.1_19

    Hello
    i am an old java programmer. but stopped for a while... so i guess im a bit rusy at it...
    anyway...
    i installed jdk1.3.1_19 on my pc and did everything as they asked for in the installation but i get an error wen i run the .CLASS file
    the error i get is:
    "exception in thread 'main' java.lang.NoClassDefFoundError: C:\jexamples\Welcome1"
    i read a documentation abt some CLASSPATH... which im kinda confused abt... how do i set that? and wat do i set it as?...
    Thanx for the help in advance!

    i am an old java programmer. but stopped for a
    while... so i guess im a bit rusy at it...
    anyway...
    i installed jdk1.3.1_19 on my pc Why did you install an old version instead of the latest version?
    and did everything
    as they asked for in the installation but i get an
    error wen i run the .CLASS file
    the error i get is:
    "exception in thread 'main'
    java.lang.NoClassDefFoundError:
    C:\jexamples\Welcome1"
    i read a documentation abt some CLASSPATH... which im
    kinda confused abt... how do i set that? and wat do i
    set it as?...Do not set or use the CLASSPATH environment variable. Instead use the -classpath option when compiling or running your programs. Otherwise, you'll never figure out what's going on.
    When asking about compiling problems, you need to post:
    1) The path to all the files used in your program
    2) The prompt where you entered the commmand
    3) The actual command you entered

  • I can compile java, but I cannot run class file.

    Exception in thread "main" java.lang.NoClassDefFoundError: Demonstrate
    That is the error I get when I type: java Demonstrate
    I have "C:\j2sdk1.4.0\bin" in the path for the Environment Variables in windows xp. I've even tried to insert that into a CLASSPATH several ways and it does not change the error.
    javac Demonstrate.java works fine. That compiled file can work on other computers. Because of that, I do not think it's a setting error. Any ideas ? Thanks for any help.

    Microsoft problem? I like nothing better than bashing M$, but this sounds like a CLASSPATH problem to me.
    I'll assume that your Demonstrate.java does NOT have a package statement in it and has a main method that you'd like to run. If so, you compile like this:
    javac Demonstrate.javaThe result is a Demonstrate.class file in the same directory as Demonstrate.java.
    Now, type this in the command shell right in the directory where Demonstrate.class lives to run it:
    java -classpath . DemonstrateYou won't get that ClassNotFoundException.
    Whenever you see that exception, it means you don't have your CLASSPATH set properly. - MOD
    You won't get ta

  • Why require cap file why not only class file as in java

    why do we convert .class to .cap file why not simply load the .clss file to the card

    If Java Card has to accept .class file, it's certain
    that JCVM developers are going to spend more and more
    nights in their office.
    Just kidding. I'm one of them.LOL :)
    Put the CAP file converter on-card.

  • Java ME SDK 3.0 does not run sample files, but WTK 2.5.2 does

    Hi guys,
    I have following problem: I am using the Java ME SDK 3.0 and I am trying to run some sample MIDlets. For example this very basic HelloMIDlet which can be found here http://developers.sun.com/mobility/midp/articles/wtoolkit/src/HelloMIDlet.java
    Build runs successfully, but if I try to run it, the emulator appears, but nothing happens. Here is a warning from the logfile:
    Starting emulator in execution mode
    Installing suite from: http://127.0.0.1:3607/HelloMIDlet.jad
    [WARN] [rms     ] javacall_file_open: _wopen failed for: C:\javame-sdk\3.0\work\0\appdb\_delete_notify.dat
    [WARN] [rms     ] javacall_file_open: _wopen failed for: C:\javame-sdk\3.0\work\0\appdb\_ch_suite.raw
    bdj-run:
    cdc-run:
    profiler.check:
    open-profiler:
    run:
    BUILD SUCCESSFUL (total time: 20 seconds)The exact same source code used with the WTK 2.5.2 builds and runs without a problem. Any ideas what the problem is?
    Thanks a lot,
    iobytrap

    1. Start ME SDK
    2. File -> New Project -> MIDP Application
    3. Select Project Name AND(!) check "Create Hello Midlet". Click "Next"
    4. Select Device "DefaultCldcPhone1"; other as Default; Click Finish
    5. Change body of the HelloMidlet.java according to http://developers.sun.com/mobility/midp/articles/wtoolkit/src/HelloMIDlet.java
    //As you described
    6. Click F6 (Run Main Project)
    As a result: "BUILD SUCCESSFUL"; ME SDK open with "Hello,World".
    So, all works. Please provide step by step scenario if you see problem yet. Also tell me please version of java.
    Regards,
    Mikhail.

  • Unable to compile ( not creating class file ) java file

    Hi
    I am unable to compile java file in eclipse. I am using Tomcat 5.0 and eclipse 3.0. I am able to compile the file from command prompt. I installed eclipse and did all settings including Build path ( WEB-INF\classes). But I donot see any class file getting created.

    Are you seeing errors when eclipse compiles you classes? Have you tried to build your project using; Project -> Build All? If you have and it looks like no errors are generated you may need to change your perspective. Try changing to the resource perspective to see the built class files; Window -> Open Perspective -> Other -> Resource. By default built class files end up in the bin directory of the project. i usually change my built classes directory to classes, just makes more sense to me.

  • How to run class files in a jar independently.

    Hello all
    I have a java file which use an API.jar file which is an API file of some other application of mine.This file form a sought of client for that application.Now i want to run this file from command line which is giving NoClassDefFoundError exception.This exception is because of the dependency over API.jar.I dont want to pack this single file into a jar and then run that jar since it only makes a simple task complicated and makes a simple class look like a big application.Can anybody tell me the solution to it?
    Regards,
    Mansi

    MansiSachar wrote:
    I am working on WindowsXP and the command u just sent is again giving the same exception.The exception is :
    Exception in thread "main" java.lang.NoClassDefFoundError: ûcp
    Caused by: java.lang.ClassNotFoundException: ûcp
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    I think the problem can also be the placement of the dependant jars.do i need to keep them in "bin" folder?I am assuming that in the error message, it says "-cp" not "ûcp" Can you confirm that you entered the command as posted? Because it looks like java.exe sees the -cp as the class to execute instead of the classpath option.
    Try using -classpath instead of -cp. What version of java are you using? (java -version should give you the version).
    If the jars are in the current directory, the placement of the jar files is correct.

  • Running  .class file from autoexec.bat (in Windows Xp environment)

    How to run a .class file from autoexec.bat file. I have WinXP installed on my PC. I tried the solution given by Forum memebers but they didn't work.
    after setting the classpath
    i wrote
    java -cp simple in autoexec.bat , but results were not satisfactory.

    What does "not satisfactory" mean? If the commans works from any .bat file, it'll work from autoexec.bat, too.
    May I ask what you're trying to accomplish? I'm not sure whether XP dtill uses autoexec.bat for console initialization after all.

  • Cannot run .class file.  What's wrong, please?

    Hi,
    I have installed J2SDK1.4.2_03 in D: drive in folder JavaApplications.
    Have appended the path: ;D:\JavaApplications\bin in System Variable.
    Written a simple program named WhatIsYourName.java and saved in D:\JavaPractices
    At D:\JavaPractices> compile the program using javac WhatIsYourName.java and it is OK
    At D:\JavaPractices> checked directory and the WhatIsYourName.class file is there.
    When typed: java WhatIsYourName
    Error message appears:
    Error: could not open C:\Program Files\Java\j2re1.4.2_03\lib\i386\jvm.cfg
    Reinstalled J2SDK1.4.2_03 in D: drive in folder JavaApplications again, same error.
    When I checked the C:\Program Files, there is a bin and lib folders residing in a 1.3.1_07 folder in the JRE folder. The JRE folder is found in a folder called JavaSoft. Is it because of this that the error occurred?
    Could not understand why?
    Please help.
    Thank you very much.
    Theophilus

    Hi ChuckBing,
    You are right. The older version is being found first. After removing the older version I can run the .class file.
    Need to ask you about checking the full path when invoking java which you suggested. At D:\JavaPractices directory am I supposed to type \JavaApplications\bin\java WhatIsYourName ? I don't quite get what you mean.
    Thank you very much.
    Theophilus Mah

Maybe you are looking for

  • How do I transport an MP3 file to play elsewhere

    I'm trying to save MP3 files of a national talk show host- Bruce Williams, in a way that I can play these files in the car. Each of these files is 1 hour long and somebody in the forum said that I could only get 1 hour saved on each CD, which is righ

  • I am having trouble with a URL importation and URLRequest

    package import flash.display.MovieClip; import flash.events.MouseEvent; import flash.events.TimerEvent; import flash.net.URLRequest; public class PixelSlaves extends MovieClip private var _origXScale:Number; private var _origYScale:Number; private va

  • Standard Report for all inspection lots

    Dear all, Pls guide me from where I can retrieve the data for result recorded for MIC, inspection lot wise. Actually currently working for Pharma company where we are using, Inspection Plan (task list type Q), with inspection point 200 u2013 Physical

  • Name of WP trace file

    Hi all, In my system I can see that my WP trace files are named like dev_w + number, but I have found function module GWY_READ_WP_FILE which is using hardcoded value dev_wp + number. My question is, is it an error in this FM or have these files in pa

  • Dynamic Approval Levels In RFX

    Hi, I Have requirement i.e  Approvers are determined on the basis of Purchasing Group. Approval Levels May Vary  Depending Up on the Purchasing Group. I have seen lot of threads in this forum regarding this . BRF needs to be implemented for this . Bu