aspose file tools*
The moose likes Beginning Java and the fly likes Text Pad help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Text Pad help" Watch "Text Pad help" New topic
Author

Text Pad help

khoa tran
Greenhorn

Joined: Jun 19, 2013
Posts: 8
Hello all!

I'm currently using textpad 7 and I am having some problems running a script. I'm trying to run the basic

public class HelloWorld
{
public static void main (String[] args)
{
System.out.println("Hello World!");
}

}

At first I didn't have the compile and run commands but I fixed that. When I compile it, it generates a .java file no problem. When I run it however it states:

Error: could not find or load main class hello
press any key to continue.

I noticed textpad didn't generate a .class file. I attempted to do it manually with the cmd prompt. I used cd to browse to the directory my hello.java file was in. I then typed in:

javac hello.java

I received this error:

'javac' is not a recognized as an internal or external command, operable program or batch file.

my JDK and textapd 7 is installed properly and I don't know where to go from here.

Please help!



Aj Prieto
Ranch Hand

Joined: Sep 28, 2012
Posts: 75

Did you set your PATH variable?

http://docs.oracle.com/javase/tutorial/essential/environment/paths.html


Da mihi sis bubulae frustum assae, solana tuberosa in modo Gallico fricta ac quassum lactatum coagulatum crassum.
khoa tran
Greenhorn

Joined: Jun 19, 2013
Posts: 8
yes, in the path variable I have

C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\; C:\Program Files\Java\jdk1.7.0_25\bin

I wasn't sure what the old path was so I put in a ; to separate the two. Does that not work the way I think it does?
khoa tran
Greenhorn

Joined: Jun 19, 2013
Posts: 8
I tried to run the code again, I noticed now that when I compile I get the error

C:\Users\Jonsen\Desktop\College\hello.java:1: error: class HelloWorld is public, should be declared in a file named HelloWorld.java
public class HelloWorld
^
1 error

Tool completed with exit code 1
Charles D. Ward
Ranch Hand

Joined: May 12, 2013
Posts: 50
    
    1
Shouldn't your file name match your class name? I think that error message is very clear.
khoa tran
Greenhorn

Joined: Jun 19, 2013
Posts: 8
Charles D. Ward wrote:Shouldn't your file name match your class name? I think that error message is very clear.

You're right I fixed that now. It puts out this error

javac: file not found: C:\Users\Jonsen\Desktop\College\hello.java
Usage: javac <options> <source files>
use -help for a list of possible options

Tool completed with exit code 2
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3018
    
  10
Ummm... are you still typing

javac hello.java

?

Try replacing it with

javac Hello.java
khoa tran
Greenhorn

Joined: Jun 19, 2013
Posts: 8
public class HelloWorld
{
public static void main (String[] args)
{
System.out.println("Hello World!");
}

}

I found my problem it was the capital on line 1 HelloWorld
^
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14274
    
  21

If you have a public class named HelloWorld, then you should save that in a file named HelloWorld.java. Not: hello.java, Hello.java, helloworld.java or anything else. The name of the source file should be exactly the same as the name of the public class that it contains. Note that case matters for Java, even though filenames are not case-sensitive according to Windows.

Compile it from the command line with:

javac HelloWorld.java

You should then have a file named HelloWorld.class. Run it with:

java HelloWorld

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
 
subject: Text Pad help