Question:
Java Program Package Problem?
kalpesh
2010-10-14 23:32:21 UTC
I have two program as follow

package cert;

public class Sludge
{

public void testIt(){
System.out.println("Sludge ");
}

}


and second

package book;

import cert.*;

class Goo extends Sludge
{
public static void main(String[] args)
{
Sludge o=new Sludge();
o.testIt();
System.out.println("Hello World!");
}
}

and i save these on one of the drive of system


i have error at compile time of Goo.java that
package cert does not exits
Four answers:
?
2010-10-18 01:01:53 UTC
Remove statement "package book" in the second prgm...

create a Folder naming "cert"..

for ex.. I have created a folder "cert" in E:\

Then save the file Sludge.java in E:\cert\Sludge.java

then compile the Sludge.java i.e: E:\>cert\javac Sludge.java

then save the file goo.java in E:\>

then compile and run the goo.java as E:\>javac goo.java

E:\>java goo



Your Output:

Sludge

Hello World!
Donnqa
2010-10-15 00:06:58 UTC
be careful with java it should be already in your system if it appears as update java click the do not show this message then close it of because this a real bad trojan it will kill your computer and you will have to format your computer or if you have malware bytes installed on your computer which you can download yourself for free just type in malware bytes free download depending on system you use i always download from brothers when it has installed you always have update it for a scan it will say update complete close any programs of then do a full scan if it finds anything after the scan it will say show results also a note pad wil appear just telling you what you have got close it of and go to show results delete all then go back into your quarantine again then remove all now if you can get into any programs at all reboot your computer and just keep on pressing the f8 button until the page loads it will say start windows normally use your arrow buttons and go up to where it says networking in safe mode click on that and you can do a scan that way and it will sort it if you want to get the proper java go to the microsoft website and just type in java and also go to security alerts etc and download the latest anti-virus program when it installs it will do a scan then update it after the scan and then go to the tool box ion or settings and you can decide what you want to do with each program alerts in high mode remove all in middle mode well that's up to you and you can also do a full scan in boot up just set the time and date and this does it automatically so warn any all your friends etc about java
Sayee
2010-10-15 00:46:49 UTC
Looks fine. Use an IDE to compile and run like eclipse or Netbeans. Its much easier. I think you are trying to use command line to compile and run: in that case look for instructions on how to compile (in google or bing)

Again: Code is correct.
Subhanker
2010-10-15 00:34:07 UTC
use different class


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