It's not a secret anymore!
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
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.

I agree. Here's the link:
subject: Not able to create package
jQuery in Action, 3rd edition