aspose file tools*
The moose likes Beginning Java and the fly likes Does JDK1.3.0_02 require package stmt? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Does JDK1.3.0_02 require package stmt?" Watch "Does JDK1.3.0_02 require package stmt?" New topic
Author

Does JDK1.3.0_02 require package stmt?

Gary Farms
Ranch Hand

Joined: Jun 24, 2000
Posts: 57
Does the JDK1.3.0_02 require a package statement at the top of
every .java file, even a simple HelloJava program??
That seems to be the case! My simple HelloJava.java program will compile but won't run in c:\java. It looks as follows:
public class HelloJava
{
public static void main(String[] args)
{
System.out.println("Hello World from Java");
}
}
However, if I do 2 things it will run. These 2 things are:
1. add "package com.gfarms.geometry;" as the 1st line of program
2. copy HelloJava.java to c:\java\com\gfarms\geometry and
compile it there
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Gary,
No it doesn't! What you have described is just the default way that java has always treated the package statement. If it exists then you must place in into the same named directory structure.
If you don't use the statement you need to set your CLASSPATH variable. At a minimum, it should have "." as a path so that you can sit in the directory in which your *.class file exists and run it.
Regards,
Manfred.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Gary,
Try going to your DOS prompt and typing "set" and looking to see if your classpath is REALLY what you think that it is.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Does JDK1.3.0_02 require package stmt?