[RESOLVED] NoClassDefFoundErr
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: [RESOLVED] NoClassDefFoundErr

  1. #1
    Join Date
    Sep 2011
    Posts
    197

    [RESOLVED] NoClassDefFoundErr

    Code:
     
    package codeBreaker;
    
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.Writer;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.BufferedInputStream;
    import java.io.PrintWriter;
    public class depth {
    
    public static int deCode;
           
     
    
                    public static void main(String[] args) {
       String UI;
       inCodeHandler ih = new inCodeHandler();
       System.out.println("Text you want encoded:");
            try(InputStreamReader isr = new InputStreamReader(System.in); BufferedReader 
    
    br = new BufferedReader(isr)) {
              UI = br.readLine();
            ih.storE(UI);
    } catch(FileNotFoundException fn) {
                      System.err.format("FNF Err@: %s%n FNF ErrMessage: %s%n", 
    
    fn.getStackTrace(), fn.getMessage());
     
          }catch(IOException ioe) {
                      System.err.format("ioe Err@: %s%n ioe ErrMessage: %s%n", 
    
    ioe.getStackTrace(), ioe.getMessage());
          }
         }
      }

    Code:
    package codeBreaker;
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.Writer;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.BufferedInputStream;
    import java.io.PrintWriter;
                     
    
          
    
         
    
                           public class inCodeHandler {
                    
    
    
      
         
    public static void storE(String input) {
      BufferedWriter bw;
      try { 
            bw = new BufferedWriter(new FileWriter("Coded.txt", true));
            bw.write(input); 
            bw.newLine();
            bw.flush();
      } catch (IOException ioe) { ioe.printStackTrace(); }}
    
    public static void readInput() {
                   String input;
            try {
             InputStreamReader isr = new InputStreamReader(System.in);
             BufferedReader br = new BufferedReader(isr);
             input = br.readLine();
       Case1:
            if(input.equals("a")) {
              storE("7sd5f4s2");
            } else if (input.equals("The"))  { 
               storE("7hj5f6s"); }
    
        } catch (IOException e){
          System.out.println("Error reading from user");
       } 
      }
    }

    I changed the dept class I invoked store like this instead

    Code:
     
    inCodeHandler.storE(UI);


    Anyways, here's the error I get either way I invoke storE.

    Code:
    Error: Could not find or load main class java
    Press any key to continue . . .
    It's just odd to me that it would give me this message I am not invoking the inCodeHanlder class. Just a method.. I could just simply add a main class, but I want to know why it's giving me this error. So that's what I'm asking form this overly drawn out post. I just want to know why it's giving me this error when I'm not calling the class, just a method.

    P.S: I just realized that I used storE when I should have been using readInput. So I changed it did same thing with readInput as I did with storE and, the same problem persisted.
    Last edited by kolt007; October 7th, 2011 at 04:48 PM.

  2. #2
    Join Date
    Jan 2011
    Posts
    24

    Re: NoClassDefFoundErr

    It looks you are running a class which doesn't have public static void main () method. Can you post your java command ?

  3. #3
    Join Date
    Sep 2011
    Posts
    197

    Re: NoClassDefFoundErr

    I don't know what you mean java command. And, I don't need a main method because, I'm not calling the class inCodeHandler, I'm calling a specific method. Which would not require inCodeHandler to have a place to start like main methods.

  4. #4
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: NoClassDefFoundErr

    If you format your code properly as I've repeatedly suggested you do I'll look at it.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center