• Post Reply Bookmark Topic Watch Topic
  • New Topic

Making an array returning error  RSS feed

 
Miley Johnson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I am coding a small project that has a cds and shelf classes - and when I try to make an array from the first one I get the error message: ".class" expected."

The first array I make works fine which is:
ALLCDS[] cd = new ALLCDS[9];

but the second one:
Shelfx[] shx = new Shelfx[10];

doesn't work. Here is a SS:
http://imgur.com/a/C7Qow
 
Ganesh Patekar
Bartender
Posts: 726
23
Eclipse IDE Hibernate jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

Can you post your code?   please use code tags to post your code, click here ---> UseCodeTags to know how to use code tags.
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get the error message
Also please copy the full text of the error message and paste it here.  Compiler error messages should show the source line where the error happened.
 
Miley Johnson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks =)

main app:



ALLCDS:
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you also copy and paste here the full text of the error message?
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message is visible in the attachment.

Miley, can you show us the lines just in front of this line? Because I don't see any errors on the line itself, but perhaps there's an error on a previous line that confuses the compiler.
 
Paul Clapham
Sheriff
Posts: 22843
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:Miley, can you show us the lines just in front of this line? Because I don't see any errors on the line itself, but perhaps there's an error on a previous line that confuses the compiler.


That would be line 22 in the posted code, which does indeed have a problem which confuses the compiler.
 
Ganesh Patekar
Bartender
Posts: 726
23
Eclipse IDE Hibernate jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although you add semicolon ; on line number 22,  at runtime you might get ArrayIndexOutOfBoundsException because array size of type ALLCDS is 9 and in for loop you are trying to assign references of objects to array index which are out of bounds of that array. Please see line numbers 12 and 13.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:
Rob Spoor wrote:Miley, can you show us the lines just in front of this line? Because I don't see any errors on the line itself, but perhaps there's an error on a previous line that confuses the compiler.


That would be line 22 in the posted code, which does indeed have a problem which confuses the compiler.

I thought there was something after that, because the snippet says "etc".
 
Paul Clapham
Sheriff
Posts: 22843
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:I thought there was something after that, because the snippet says "etc".


That could be. Although if we're asked about error messages arising from some code and then we're shown some different code, it wouldn't be surprising if we provided useless answers.
 
Miley Johnson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I checked the lines preceeding the shelf array, and noticed that I hadn't finished the list ^^ fixed up the for loop too. http://imgur.com/a/W1qmu

will post app in a bit
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Miley,

I'd say you better post actual code rather than show us URL's to code images.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although I agree, I think the images already show the cause of the error.
 
Miley Johnson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

so I finished writing the code - I am trying to compile it into a .jar file;
: all classes are working
- added manifest
- cannot find or load main class?

http://imgur.com/a/gp8fZ
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you build the jar file?
Does the jar file have a manifest file with a Main-Class: record?
Is the referenced class in the correct folder in the jar file?

How did you try to execute the jar file?
 
Miley Johnson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used the -e option for jar to build the manifest for me, tried earlier with manifest file, but didn't work.
The vinylshop.class is in the same folder as with the .jar. The app works outside, so dunno what's up with the jar.
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you look in the jar file using a zip utility program?  See if the manifest file has the Main-Class: line
and if the class shown on that line is in the correct folder for the package it is in?

used the -e option for jar 

Can you copy and paste here the full contents of the commandline used to build the jar file?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!