Accesing a method from another java file

i had written two java files, firstcalss1.java and moreclass1.java. And i tried to access a method from firstclass1.java .. the code is below...

firstclass1.java

--

import java.io.*;

public class firstclass1

{

public firstclass1()

{

}

public void printname()

{

System.out.println("This is the first class, name is xxxxxx ");

}

}

moreclass1.java

--

import java.io.*;

class moreclass1

{

public static void main(String args[])

{

firstclass1 ob1 = new firstclass1();

ob1.printname();

System.out.println(" This is the main class .....");

System.out.println("hai ");

}

}

But i got an error that cannot resolve the symbol firstclass1..

how can i solve this..

[826 byte] By [Manomohan.M.Ka] at [2007-11-27 6:19:06]
# 1
> But i got an error that cannot resolve the symbol> firstclass1..> > how can i solve this..more info neededexactly how did you invoke compiler?
OnBringera at 2007-7-12 17:33:25 > top of Java-index,Java Essentials,New To Java...
# 2
i had given like below..javac moreclass1.java
Manomohan.M.Ka at 2007-7-12 17:33:25 > top of Java-index,Java Essentials,New To Java...
# 3
yes more info needed.you have the java files in the same directory/package?try using the 'package' keyword in the java files, maybe it helps.(package specification should be the first non-comment line in each java file)
tom_jansena at 2007-7-12 17:33:25 > top of Java-index,Java Essentials,New To Java...
# 4
And can you post the full compiler error msg.Here it works: I just paste your two files in a common directory and run javac like you did.(Except I have to prepent C:\Program Files\Java\jdk....)
tom_jansena at 2007-7-12 17:33:25 > top of Java-index,Java Essentials,New To Java...
# 5

the below is the full error....... before this i compied the firstclass1.java using the command javac firstclass1.java.. and here i am using the fedora as operating system..

moreclass1.java:9: cannot resolve symbol

symbol : class firstclass1

location: class moreclass1

firstclass1 ob1 = new firstclass1();

^

moreclass1.java:9: cannot resolve symbol

symbol : class firstclass1

location: class moreclass1

firstclass1 ob1 = new firstclass1();

^

2 errors

Manomohan.M.Ka at 2007-7-12 17:33:25 > top of Java-index,Java Essentials,New To Java...
# 6

Hi ,

I think this will help you ,

Lets suppose you have two classes ,

1>- Test17.java

2>-Test18.java

Now watch the Test17.java code carefully,,,,

import java.io.*;

public class Test17

{

public Test17()

{

}

public void printname()

{

System.out.println("This is the first class, name is xxxxxx ");

}

}

Here the Test18.java code ,,,,

import java.io.*;

class Test18

{

public static void main(String args[])

{

Test17 ob1 = new Test17();

ob1.printname();

System.out.println(" This is the main class .....");

System.out.println("hai ");

}

}

I think this will help you ,

Thanks ,

Sb.

sb.majumder_07a at 2007-7-12 17:33:25 > top of Java-index,Java Essentials,New To Java...
# 7
you should take two different files , 1. Test17.java 2.Test18.java
sb.majumder_07a at 2007-7-12 17:33:25 > top of Java-index,Java Essentials,New To Java...
# 8
This is that i had written ... it is not working... and i put the files in same directory
Manomohan.M.Ka at 2007-7-12 17:33:25 > top of Java-index,Java Essentials,New To Java...
# 9
that problem has been solved...compile both file in a single line..javac firstclass1.java moreclass1.javaThen it will work..
Manomohan.M.Ka at 2007-7-12 17:33:25 > top of Java-index,Java Essentials,New To Java...
# 10
that's surprising me because here I only runjavac moreclass1.javaand then both firstclass1.class and moreclass1.class are generated.
tom_jansena at 2007-7-12 17:33:25 > top of Java-index,Java Essentials,New To Java...