Compiling My First Project

It is probably me, but I can not get anything to compile with IntelliJ Idea 10.0.2 on my Win7 (64bit) machine.

After installing IntelliJ Idea, I goto File -> New Project -> Create project from scratch, and name it "untitled3" with the rest defaults (project files location is C:\Users\Kyle\IdeaProjects\untitled3).  I click Next, and keep "Create source directory" selected.  And click Finish.

I make a new class in the "src" directory, and call it "test".  I add three lines to the autogenerated code to result in:

* Created by IntelliJ IDEA.
* User: Kyle
* Date: 22/03/11
* Time: 11:53 AM
* To change this template use File | Settings | File Templates.
public class test {
    public static void main(String[] args){
        System.out.println("Hellow World");

And then select Build -> Rebuild Project.  After a second there is "Compilation completed successfully" in the bottom left.  A scan of my whole drive show no "test.class" anywhere.

Needless to say, a right click on the "test" file, and selecting 'Debug "test.main()"' results in a ClassNotFoundException:

C:\java6\bin\java -agentlib:jdwp=transport=dt_socket,address=,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath "C:\java6\jre\lib\alt-rt.jar;C:\java6\jre\lib\charsets.jar;C:\java6\jre\lib\deploy.jar;C:\java6\jre\lib\javaws.jar;C:\java6\jre\lib\jce.jar;C:\java6\jre\lib\jsse.jar;C:\java6\jre\lib\management-agent.jar;C:\java6\jre\lib\plugin.jar;C:\java6\jre\lib\resources.jar;C:\java6\jre\lib\rt.jar;C:\java6\jre\lib\ext\dnsns.jar;C:\java6\jre\lib\ext\localedata.jar;C:\java6\jre\lib\ext\sunjce_provider.jar;C:\Users\Kyle\IdeaProjects\untitled3\out\production\untitled3;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 10.0.2\lib\idea_rt.jar" test
Connected to the target VM, address: '', transport: 'socket'
java.lang.NoClassDefFoundError: test
Caused by: java.lang.ClassNotFoundException: test
    at$ Source)
    at Method)
    at Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
Disconnected from the target VM, address: '', transport: 'socket'
Could not find the main class: test.  Program will exit.
Exception in thread "main"
Process finished with exit code 1

So, what am I missing?   I tried with my old version of 7.0.2 also, and same thing.  I never had this problem when I was using IDEA a few years ago (but that was on XP).  


Comment actions Permalink

Just tested creating here a test class without a package and run/debug worked here (don't usually create files without packages, so tested to see if this still works :) .)

A scan of my whole drive show no "test.class" anywhere.

That's... strange. Check that your anti-virus isn't eating the file (disable it?).
Comment actions Permalink

A good friend, and someone much brighter than me, figured out the problem:

Spaces in the Win7 paths was causing the problems.  Goto File -> Settings -> Compiler -> Java Compiler and select a JVM without spaces in it's home path.  Everythingnow works.

It is unfortunate that I got "Compilation completed successfully".  The compiler really should check to make sure it something was created.

Comment actions Permalink

On Tue, 22 Mar 2011 19:05:38 MSK, kyle lahnakoski
<> wrote, quoted or indirectly quoted someone
who said :

>It is probably me, but I can not get anything to compile with IntelliJ Idea 10.0.2 on my Win7 (64bit) machine.

I have made some notes that might help you get started.

Give things proper names.  Temporary meaningless names will just help
confuse you.

Roedy Green Canadian Mind Products
If you think it’s expensive to hire a professional to do the job, wait until you hire an amateur.
~ Red Adair


Please sign in to leave a comment.