Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7043213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:15:43+00:00 2026-05-28T02:15:43+00:00

I am still trying to learn Java and decided to take it 1 step

  • 0

I am still trying to learn Java and decided to take it 1 step further and attempt to use external class files to store data structures (like the header files in C). I keep running into NoClassDefFoundError and would like some methods or techniques that can show me what is going wrong (and where) as the message is not very clear to me 🙁

I have my directory structure set up as follows:

tarskin@5-PARA-11-0120:~/programming/Java/FindGlycopeps$ ls
Default.mzML  FindGlycopeps.class  FindGlycopeps.java  glycoproteomics
tarskin@5-PARA-11-0120:~/programming/Java/FindGlycopeps$ ls glycoproteomics/
Spectrum.class  Spectrum.java

The ‘main’ program is coded as follows:

package glycoproteomics;
import java.util.*;
import java.util.regex.*;
import java.io.*;
import java.lang.*;

public class FindGlycopeps {

public static LinkedList outside_tag_reader (String filename, String tag) {
        LinkedList<String> someList = new LinkedList<String>();
        DataInputStream in = null;
    try {
        FileInputStream input = new FileInputStream(filename);
        in = new DataInputStream(input);
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line;
        String regexp = "<"+tag+">(.*)</"+tag+">";
        Pattern pattern = Pattern.compile(regexp);
        while ((line = reader.readLine()) != null) {
            Matcher matcher = pattern.matcher(line);
            if (matcher.find()) {
                String buffer = matcher.group(1);
                someList.add(buffer);
            }
        }
        in.close();
    } catch (Exception x) {
        System.err.println(x);
    }
    return(someList);
}

public static void main (String [ ] args) {
    LinkedList<String> binary = new LinkedList<String>();
    ArrayList<Spectrum> spectra = new ArrayList<Spectrum>();
    String file = args[0];
    if (file != null) {
        binary = FindGlycopeps.outside_tag_reader(file,"binary");
        int j = 0;
        for (int i = 0; i < binary.size(); i++) {
            String buffer = binary.get(i);
            if (i % 2 == 0) {
                spectra.add(j, new Spectrum());
                spectra.get(j).mzList.add(buffer);
            } else {
                spectra.get(j).intList.add(buffer);
            }
            j++;
        }
        System.out.println(spectra.get(1).mzList); // purely for testing

        } else {
            System.out.println("No file was specified");
        }
    }
}

The ‘Data structure’ is coded as follows:

package glycoproteomics;
import java.util.ArrayList;

public class Spectrum implements Comparable<Spectrum>{
   float precursor;
   ArrayList<String> mzList;
   ArrayList<String> intList;

   public int compareTo(Spectrum arg0) {
      return 0;
   }
}

I have compiled both .java files with just javac and been attemping to run the main class, from the ‘root’ using several variations of java -classpath (also tried -cp) ./://Java/FindGlycopeps/glycoproteomics FindGlycopeps and it keeps giving errors such as:

Exception in thread "main" java.lang.NoClassDefFoundError: FindGlycopeps (wrong name: glycoproteomics/FindGlycopeps)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: FindGlycopeps. Program will exit.

What would be good ways to figure out how it is going wrong and what should be changed in my ‘thinking’? I would appreciate an explanation why something should be done instead of ‘do this to fix it’ if possible.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:15:43+00:00Added an answer on May 28, 2026 at 2:15 am

    Java class files must be in a directory with the same name as the package. So you need to add ~/programming/Java/FindGlycopeps to your classpath (and not ~/programming/Java/FindGlycopeps/glycoproteomics) and the file FindGlycopeps.class must be in ~/programming/Java/FindGlycopeps/glycoproteomics (instead of ~/programming/Java/FindGlycopeps)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Still trying to learn the basics of MVC. I'm making use of Zend_Loader for
I'm still very new to C and trying to learn how to use strptime
I am still trying to learn java, so correct me if I'm wrong. As
still trying to find where i would use the yield keyword in a real
I'm still trying to decide whether my (home) project should use UTF-8 strings (implemented
I'm still trying to get my head around using Java's generics. I have no
I am still new to Java and Eclipse and I'm trying to get my
I am trying to learn Java generics. I am not clear when you will
I'm a newcomer to JSF and am still trying to follow examples to learn
I'm from a Java/PHP background and I'm trying to learn Rails, but I'm finding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.