This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Not able to create package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Not able to create package" Watch "Not able to create package" New topic

Not able to create package

Akhil Jain
Ranch Hand

Joined: Oct 14, 2004
Posts: 74
please note: i am using Gel as Java Editor

//<----first file:----->

package mypackage;

public class class1{
private int data;
public void func(){

//<-----Second file---->

import mypackage.*;

public class class2{
public static void main(String[] args){
class1 obj = new class1();
System.out.println("Done Successfully");

i am compling the first program and it should create the package inside the main working directory but ir is not creating.

and while compling the second file its unable to get the package and hence giving package doesn't exist error.

If some can help me out then please do reply soon.

Note that i am using Gel editor for java.

-------------------------------<br />you can't move ahead, unless you try for it.
Arnaud Burlet
Ranch Hand

Joined: Oct 08, 2004
Posts: 31
your should be in a directory named "mypackage",
your should be in the same directory as "mypackge" dir.

And to have your example work, you should declare class1 constructor as public.

wood burning stoves
subject: Not able to create package
Similar Threads
Two Packages in the Same Directory?
Package & Compilation Problem
Confusion Question
package problem
Kind Attn:Marcus Green - Pl. clear doubt