Community
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Compiling Java Works, Executing Java Doesn't

 
Post new topic   Reply to topic    Community Forum Index -> Java
View previous topic :: View next topic  
Author Message
Art Metzer



Joined: 06 Mar 2006
Posts: 27

PostPosted: Fri Jan 03, 2014 9:41 pm    Post subject: Compiling Java Works, Executing Java Doesn't Reply with quote

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:
Quote:
C:\Program Files\Java\jdk1.7.0_40\bin\javac.exe

and Parameters set to:
Quote:
-classpath "$FileDir;C:\Users\ArtMetzer\Documents\Technical\Java" $File

and Initial folder set to:
Quote:
$FileDir


The following code makes up C:\Users\ArtMetzer\Documents\Technical\Java\HelloWorld.java:
Code:
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:
Quote:
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:
Quote:
C:\Program Files\Java\jdk1.7.0_40\bin\java.exe

Parameters:
Quote:
-classpath "$FileDir;C:\Users\ArtMetzer\Documents\Technical\Java" $File

Initial folder:
Quote:
$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.
Back to top
View user's profile Send private message
ben_josephs



Joined: 02 Mar 2003
Posts: 2360

PostPosted: Sat Jan 04, 2014 8:46 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Art Metzer



Joined: 06 Mar 2006
Posts: 27

PostPosted: Mon Jan 06, 2014 2:44 pm    Post subject: Reply with quote

That worked! Thanks, Ben.

Art.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Community Forum Index -> Java All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB