• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Does JDK1.3.0_02 require package stmt?

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic