I need to know about package ???

S

Siripong

Dear All
I am a new java programmer and now I have some problem about java.
I have 2 files java programs.
This is a first file (User.java)

package usejava;

import java.io.*;

public class User
{
public String Name;

public User()
{
Name = "I am the man";
}
}

I can compile this file by this command

javac User.java

I can get file User.class .
And second file is Login.java .

import usejava.*;

import java.io.*;

public class Login
{
public static void main(String args[])
{
User u = new User();
System.out.println(u.Name);
}
}


When I compile second file I got error "Don't know package
usejava.*"
So I create jar file by this command.

jar cf usejava.jar *.class

And set CLASSPATH by this command.

CLASSPATH=/root/usejava.jar;export CLASSPATH;

And I compile second file again I got same error. Please let's me
know what happend and how to fix this problem.

Best Regards,
Mod X
 
B

Ben Wilson

Try recompiling your original file as follows:

javac -d . User.java

Your User.class is probably not in the directory "usejava" so javac can't
find it when it goes to compile Login.java. Read up on the "-d" flag of
javac for more information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top