Question:
Do we need java pakage to create java files?
sindhurakannappan
2006-04-21 04:33:51 UTC
Java is a program which is used to create webpages
Seven answers:
ch_guy87
2006-04-27 06:27:42 UTC
Simple answer: No we don't need packages to create java files. You need an editor (like textpad or ultra edit to create java files -- just save as *.java). You also don't need a package declared in your java file. They're only handy if you have a ton of java files and you want to order them in the same way you order your personal files on your computer.
2006-04-21 11:39:35 UTC
Well java is a programming language, rather than a program, and normally you'd create Java packages from Java files not the other way round. I'm not an expert with Java, but to the best of my knowledge, it works like this:



Java files are compiled to make Class files

Class files are combined together to make Java packages



As far as I know you can execute Java programs just using the class files, you don't *have* to make packages, but most coders do because it's much easier to organise.

There are probably some thing you can't do with Java unless you make your code into packages, but off the top of my head I wouldn't know what they were...



If you mean "What do I need to program in Java?" then you need something called the JDK (Java Development Kit) which is available from SUN:



http://java.sun.com/j2ee/1.4/download.html
shvelmur
2006-04-23 06:54:22 UTC
Firstly, that is a very vague question. What are you trying to do with Java in the first place?!



If you already know it is a programming language, and are asking about whether it is necessary to use the package keyword, at the begining of every java file, then no, you do not need a package to create java files.



If no package keyword is used, the java file is considered to be under the default package. You might also want to understand the need for packages as explained below



Need for packages

1. Namespace partitioning.

Every java file declares one or more classes. Each class should have a unique name in a namespace. The package keyword allows you to partition the namespace and hence ensure uniqueness of the class name.



eg.



Let us say you want to write a HashMap class for you company, which allows duplicates.



However there is already a class called HashMap in java.util package. If you still want to write your own class with the same name you may do so within your own package.

com.somecompany.util.HashMap.



Now each class can be indentified as below



java.util.HashMap hm = new java.util.HashMap();

com.somecompany.util.HashMap hm1 = new com.somecompany.util.HashMap();



2. Grouping of related classes.



Classes providing some common functionality can be groped as a package.



eg.

java.util - Utility classes (collection classes, Stirng etc)

java.lang - Classes implementing language fundamentals

java.io - Input/Output classes.
GearSpecâ„¢
2006-04-21 11:52:12 UTC
You will need JAVA Software Developement Kit(SDK) or JAVA NETBEANS in order to compile the text file which contains your coding.



JHTML is the language used to creat webpages. But Nowadays Dreamweaver and Macromedia is taking too much control. And yes Pearl and PHP are also used widely.
Brian
2006-04-21 23:33:17 UTC
Packages are simply a way to organise your java files. For example, all java files in your program that deal with email could be put in a package called "myprogram.mail". Files that deal with pictures could be put in a package called "myprogram.images", etc.



The package statement is usually the on the first line of the file, e.g.:





package myprogram.images;





This helps make the code more readable, and is actually recommended.



However, it is not a must that you use packages.
borngenious
2006-04-21 11:45:07 UTC
In order to make programs in JAVA u need the development kit

like j2sdk1.4.2_04 or latest version.



For webpages u can directly write ur JAVA code into pages

& save them as *.jsp.
Tom
2006-04-21 11:37:11 UTC
A notepad is enough to creat a java file.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...