title: Having troubles compiling Java programs
body: <p>Sorry I couldn't be more specific with the question itself. Here's what I'm running: Windows 7 64bit, JDK v7, JRE v7 (64 bit), and JRE v6 (32 bit). I'm pretty new when it comes to Java, however I do know how to compile a program and all that stuff. I kept getting an error when I tried running my compiled programs:</p>
  
  <pre><code>C:\Users\Sean\Documents\JAVASTUFF\Chapter 3\1&gt;javac ch3p1.java
  
  C:\Users\Sean\Documents\JAVASTUFF\Chapter 3\1&gt;java ch3p1
  Error: could not open `C:\Program Files (x86)\Java\jre6\lib\i386\jvm.c
  
  C:\Users\Sean\Documents\JAVASTUFF\Chapter 3\1&gt;java -cp ch3p1
  Error: could not open `C:\Program Files (x86)\Java\jre6\lib\i386\jvm.c
  
  C:\Users\Sean\Documents\JAVASTUFF\Chapter 3\1&gt;java cd3p1
  Exception in thread "main" java.lang.NoClassDefFoundError: cd3p1
  Caused by: java.lang.ClassNotFoundException: cd3p1
          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)
  Could not find the main class: cd3p1.  Program will exit.
  
  C:\Users\Sean\Documents\JAVASTUFF\Chapter 3\1&gt;java -version
  java version "1.6.0_29"
  Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
  Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode, sharing)
  </code></pre>
  
  <p><em>note that it couldn't find the file because I had changed the folder name to see if it  would automatically detect the 64 bit JRE I have installed</em></p>
  
  <p>However, after enough searching I found a page that stated my problems were because I was running a program I compiled on JDK v7 in JREv6. I messed around with that for a little while, trying to get it to run in the JRE that came with my download of JDK. </p>
  
  <pre><code>CD: C:\Users\Sean\Documents\JAVASTUFF\Chapter 3\1
  Current directory: C:\Users\Sean\Documents\JAVASTUFF\Chapter 3\1
  javac ch3p1.java
  Process started &gt;&gt;&gt;
  &lt;&lt;&lt; Process finished.
  C:\Program Files\Java\jre7\bin\java.exe ch3p1
  Process started &gt;&gt;&gt;
  Error: Could not find or load main class ch3p1
  &lt;&lt;&lt; Process finished.
  </code></pre>
  
  <p>I'm using Notepad++ and NppExec to compile faster, and I gave up trying to get it to run JRE v7 and just used the location of it. And here's my NppExec code (I don't know if it's important, but I'll post it anyways): </p>
  
  <pre><code>cd $(CURRENT_DIRECTORY)
  
  javac $(FILE_NAME)
  
  C:\Program Files\Java\jre7\bin\java.exe $(NAME_PART) 
  </code></pre>
  
  <p>And, finally, here's the actual program I'm trying to get to run: </p>
  
  <pre><code>public class ch3p1
  {
      public static void main(String args[])
      {
          System.out.print("Hello.");
      }
  }
  </code></pre>
  
  <p>So, a quick recap. The first error I found out was because I was compiling and running a program with different versions of JDK and JRE. I couldn't figure out how to actually make it run with the JRE that came with my JDK installation so I used the direct path to it instead. My hopes got crushed that this would work when I went to run my compiled program. I got a simple "Error: Could not find or load main class ch3p1". </p>
  
  <p>What's the question? I don't know exactly, the broad question is: What do I need to do to get this to work? I cannot be any more descriptive than that because I have no idea what to do or where to look next. I'm hoping I provided enough useful information and structured it well enough to make it comprehensible. </p>
  
  <p>Some other questions: Will removing the two Java 6 updates in my Add/Remove Programs work? How do I change it so whenever it runs java, it'll run the 64bit JRE v7? </p>
  
  <p>I have no idea what I'm doing here and I'm basically learning as I go. I am familiar with computers to an extent but I am new to Java and JDK so I don't know much about how it works. My leads might be completely misdirected and wrong, if so, please correct me. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I understand that there are a lot of questions on this website and I'm sure the people posting here answer a lot of questions that can be solved with minimal to no effort involved. I have to say that I have looked everywhere and I came here to post this because I simply cannot find the solution to my problem. I wasn't looking for help on finding another program to use, and I definitely was not putting the files in my Java installation directory because despite me being new to Java, I am not new to programming. That response could have been easily avoided by looking at the first example I provided, and another one where the file path to my .java and .class files can be seen in a folder in my Documents. </p>
  
  <p>I will list answers and what I have tried here:</p>
  
  <ul>
  <li><p>I reinstalled JDK <em>and</em> JRE from the Oracle website</p></li>
  <li><p>I have set my SET_HOME system variable and my Path system variable has the JDK bin directory in it. </p></li>
  <li><p>My .class file and my .java file are in the same directory, and my class and the .java file are both named the same thing, including exact cases. </p></li>
  <li><p>After I installed JDK and JRE I deleted my previous files and made a new one, and that didn't work either. </p></li>
  <li><p>I tried putting the direct locations of java and javac as suggested in a reply.</p></li>
  <li><p>I realize that there are better IDE and build programs out there, I am using javac because the class I am in right now is using javac.</p></li>
  </ul>
  
  <p>Now, for some extra questions to help me out:</p>
  
  <ul>
  <li><p>I have the Java v6.xx updates in my add/remove programs list, would removing these in any way effect anything in a positive or negative way. And would complete removal of all JDK/JRE files and re-installation change anything? </p></li>
  <li><p>Is there any known issues with using Java and Windows 7 that I might be running into.</p></li>
  <li><p>Is this an issue with JRE or JDK, because it seems to be compiling without any issues but when I go to run it is when I get the errors. </p></li>
  <li><p>Are there any other variables other than CLASS_PATH or Path that I need to set? </p></li>
  </ul>
  
  <p>I appreciate any and all help that's been given so far even though I haven't found a solution yet. </p>