Page 1 of 1

Compiling Java Works, Executing Java Doesn't

Posted: Fri Jan 03, 2014 9:41 pm
by Art Metzer
I'm having problems getting even the simplest of Java programs to run on TextPad 7.

I am running Windows 7 SP 1, 64-bit.

My Java version is 1.7.0_40.

My Ctrl + 1 tool is "Compile Java". This part is working. Under the "Compile Java" tool, I have a Command of:
C:\Program Files\Java\jdk1.7.0_40\bin\javac.exe
and Parameters set to:
-classpath "$FileDir;C:\Users\ArtMetzer\Documents\Technical\Java" $File
and Initial folder set to:
$FileDir
The following code makes up C:\Users\ArtMetzer\Documents\Technical\Java\HelloWorld.java:

Code: Select all

public class HelloWorld {

    public static void main( String[] args ) {

        System.out.println( "Hello World" );
    }
}
When I choose the "Compile Java" external tool, the Tool Output reads "Tool completed successfully", and I can see that the file C:\Users\ArtMetzer\Documents\Technical\Java\HelloWorld.class has been created.

However, when I go on to choose the "Run Java Application" external tool, the Tool Output reads:
Error: Could not find or load main class C:\Users\ArtMetzer\Documents\Technical\Java\HelloWorld.java

Tool completed with exit code 1
Here are the values I have specified for the "Run Java Application" tool:

Command:
C:\Program Files\Java\jdk1.7.0_40\bin\java.exe
Parameters:
-classpath "$FileDir;C:\Users\ArtMetzer\Documents\Technical\Java" $File
Initial folder:
$FileDir
What do I need to change, or what do I need to look into, to get my Java program(s) to execute?

It seems like the java.exe executable should be executing C:\Users\ArtMetzer\Documents\Technical\Java\HelloWorld, and not C:\Users\ArtMetzer\Documents\Technical\Java\HelloWorld.java?

Thanks,

Art.

Posted: Sat Jan 04, 2014 8:46 pm
by ben_josephs
The interpreter uses the class path to find your classes: you specify only the name of the class file, not its directory.
And you don't specify the class file's extension.
So what you need is
-classpath "$FileDir;C:\Users\ArtMetzer\Documents\Technical\Java" $BaseName

Posted: Mon Jan 06, 2014 2:44 pm
by Art Metzer
That worked! Thanks, Ben.

Art.