• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help me to find the compile error

 
Harshal Sood
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i am beginner in java,i am following Oracle certified Associate book,
on page 14 there is a code of create your on package

i am no able to compile the code

please help me to resolve this
Untitled.png
[Thumbnail for Untitled.png]
help me to find the compile error
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice you there are two package statements. That's because the code is intended to be in two different files; each in a different package. I don't think ideone supports that so you'll have to compile on your own computer.
 
Harshal Sood
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harshal Sood wrote:hi

i am beginner in java,i am following Oracle certified Associate book,
on page 14 there is a code of create your on package

i am no able to compile the code

please help me to resolve this


Thanks Jeanne Boyarsky
 
Harshal Sood
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

as suggested by you ,i compiled it on pc,but got some error
Untitled.png
[Thumbnail for Untitled.png]
 
Harshal Sood
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my code
 
Harshal Sood
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i am beginner in java,i am following Oracle certified Associate book,
on page 14 there is a code of create your on package

i am no able to compile the code

please help me to resolve this
Untitled.png
[Thumbnail for Untitled.png]
 
Chris Symp
Greenhorn
Posts: 1
Eclipse IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should try running on an actual IDE such as eclipse it will definitely benefit you. Or at least provide the full snippet so others can help diagnose.
 
Harshal Sood
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
File a

package pa;

public class a
{

}

file b

package ba;
import pa.a;
public class b
{
public static void  main(String[] args)
{
a a1;
System.out.println("run this program");
}
}
 
Campbell Ritchie
Sheriff
Posts: 51346
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
Please don't post screenshots; your code is very difficult to read.
 
Henry Wong
author
Marshal
Pie
Posts: 22092
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Your screenshot, weirdly, contains multiple different error messages, for the same command. It is also like you are doing something in a different screen, and not show us what you did.

Henry
 
Harshal Sood
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi henry

i posted my code,and use that code i got the errors.

Thanks

Harshal Sood
 
Henry Wong
author
Marshal
Pie
Posts: 22092
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harshal Sood wrote:
i posted my code,and use that code i got the errors.


It is not the code that is the issue. With Java, code in packages must be arranged in a particular way (directories). Additionally, with multiple packages, you may also need to either compile from a certain location, or via the use of the classpath.

Posting the code isn't enough. You may also need to post the directory structure, where the source files are located, how you are compiling (along with current working directory), and of course, the classpath that you may be using.

Henry
 
Harshal Sood
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
Harshal Sood wrote:
i posted my code,and use that code i got the errors.


It is not the code that is the issue. With Java, code in packages must be arranged in a particular way (directories). Additionally, with multiple packages, you may also need to either compile from a certain location, or via the use of the classpath.

Posting the code isn't enough. You may also need to post the directory structure, where the source files are located, how you are compiling (along with current working directory), and of course, the classpath that you may be using.

Henry


Thanks Henry

directory where the files are saved :C:\harshal

directory of java: C:\Program Files\Java\jdk1.8.0_111\bin

if it is possible can you please run the same code on your system and tell me whats the output

Thanks again
 
Campbell Ritchie
Sheriff
Posts: 51346
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The screenshots link has another link which tells you how to copy and paste from the command line.
Don't put your own code into the bin directory. In fact you shou‍ld create yourself a Java directory, so you can write cd java at the command line. It is very easy to create such a directory:- mkdir java Then move all your work into that directory, and as Henry has told you, the package structure must match the structure of directories in the java folder.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic