Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving trouble compiling a Java program, I am new to it. Can't figure out what to do with directories
    primarykey
    data
    text
    <p>I have been searching the web trying to find the answer to my question, but everywhere I look seems to have too complex of a solution for a beginner like me. I have been working on this project, and just now realized that I should've made a package, or something like that. The thing is though, my program was working fine until I started dabbling with it, and now it won't work at all. I am getting this error:</p> <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: BubbleSort. class Caused by: java.lang.ClassNotFoundException: BubbleSort.class at java.net.URLClassLoader.findClass(URLClassLoader.java:434) at java.lang.ClassLoader.loadClass(ClassLoader.java:672) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358) at ``java.lang.ClassLoader.loadClass(ClassLoader.java:638) Could not find the main class: BubbleSort.class. Program will exit. </code></pre> <p>Here's how my "path" looks, if I am not mistaken. I am connected to my school's Z: drive through a remote connection, and from there I have a folder called myFirstname_Lastname_A4, which then leads me to another folder called sortingzz which I believe is supposed to have only my source files, but it also ended up with my class files in there whenever I compiled. So here's what I am doing to compile.</p> <pre><code> cd myFirstname_Lastname_A4/sortingzz </code></pre> <p><code>javac *.java</code> (Works fine, this is where I end up with my Class files inside of my sortingzz folder)</p> <p><code>java *</code> (This is where I get the error)</p> <p>I am pretty sure I am just trying to run the program wrong. Before I started messing around with stuff I wasn't ready for, I used to just run the file with my main function in it, like this</p> <pre><code>javac SortingImplementation.java java SortingImplementation </code></pre> <p>And that for the most part worked fine, but I started having trouble calling certain classes from other classes, so thats when I found out I was suppose to do the packaging and importing stuff.</p> <p>In case that is the issue, I have on the top line of every source file: package sortingzz;</p> <p>and I am importing like this:</p> <p><code>import sortingzz.*</code>;</p> <p>This is correct, right?</p> <p>UPDATE:</p> <p>I decided to give up on class pathing and trying to package everything, because as usual, I am getting responses that are way over my head, and to be honest I don't think it is necessary.</p> <p>After removing package and importing from everything, and once again compiling using javac *., it actually compiles this time. However whenever I try to run my class with the main in it, SortingImplementation, it tells me that</p> <pre><code>Could not find the main class: SortingImplementation. Program will exit. </code></pre> <p>I don't get it, I am looking at the SortingImplementation.class right now, with all the other classes and java files, so I am not sure what it's trying to do.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload