import java.io.*;
package world;

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

istored this java file in world folder;
and i set the class path as
F:> set classpath = .;f:\; because my world folder in that drive
but when i am compiling it giving error
HelloWorld.java:2:class or interface expected
why this error is giving mistake is it because of class path
one more thing is when i was not using the packages it compiled the file and givng the right message
please give suggestion. I tried lot for that

package has to go before any imports - swap first 2 lines.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.