469,366 Members | 2,546 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

error when trying to run the program

50
when i am trying trying to run the program, a windows pops up with the following message:

"selection does not contain a main type"

I think that the problem is with the directories and workspace.. I dont know how to rearrange my directories.. I cannot even run any program..

Please help...

thankyou very much

christine
Sep 21 '07 #1
15 8433
r035198x
13,262 8TB
when i am trying trying to run the program, a windows pops up with the following message:

"selection does not contain a main type"

I think that the problem is with the directories and workspace.. I dont know how to rearrange my directories.. I cannot even run any program..

Please help...

thankyou very much

christine
Post the code using code tags.
Sep 21 '07 #2
Nepomuk
3,112 Expert 2GB
when i am trying trying to run the program, a windows pops up with the following message:

"selection does not contain a main type"

I think that the problem is with the directories and workspace.. I dont know how to rearrange my directories.. I cannot even run any program..

Please help...

thankyou very much

christine
What does your program look like and how are you trying to run it? If you think it's with the directories, what do they look like?

Greetings,
Nepomuk
Sep 21 '07 #3
sugard
50
i am not very familiar in using Eclipse since before I used to program with a textpad. What do I need to do exactly please?
Sep 21 '07 #4
Nepomuk
3,112 Expert 2GB
i am not very familiar in using Eclipse since before I used to program with a textpad. What do I need to do exactly please?
If you're using Eclipse, the paths shouldn't be a problem normally, as Eclipse does that automaticly.

Please post your code (or at least the class definition and main method) using CODE tags and just to make sure, tell us, what the "package explorer" (left side of Eclipse) shows.

Oh, how did you try to run it? The correct way is, to left click on the Class with your main method, choose "Run As" -> "Java Application".

Greetings,
Nepomuk
Sep 21 '07 #5
sugard
50
what are CODE tags?
When I am trying to run the program the previous name of the class that I used in that workspace is being displayed. When I edit to the correct class, still the same error came by.

QUOTE=nepomuk]If you're using Eclipse, the paths shouldn't be a problem normally, as Eclipse does that automaticly.

Please post your code (or at least the class definition and main method) using CODE tags and just to make sure, tell us, what the "package explorer" (left side of Eclipse) shows.

Oh, how did you try to run it? The correct way is, to left click on the Class with your main method, choose "Run As" -> "Java Application".

Greetings,
Nepomuk[/quote]
Sep 21 '07 #6
JosAH
11,448 Expert 8TB
when i am trying trying to run the program, a windows pops up with the following message:

"selection does not contain a main type"

I think that the problem is with the directories and workspace.. I dont know how to rearrange my directories.. I cannot even run any program..

Please help...

thankyou very much

christine
You don't need to rearrange directories; Eclipse does that for you. Simply create
a project and add your .java files to it. Next select 'Run ...', create a new launcher,
select your project and the class that contains a main method. Press 'Accept'
and 'Run'.

kind regards,

Jos
Sep 21 '07 #7
sugard
50
I have this code which is not finished yet and it is not a launcher

Expand|Select|Wrap|Line Numbers
  1. public class Matrix {
  2.  
  3. /*    public static int[] randomIntArray(int length, int n)
  4.     {
  5.         int[] a = new int[length];
  6.         Random generator = new Random();
  7.         // for each item in the list
  8.         (for int i = 0; i < a.length; i++) {
  9.             // create a new random number
  10.             a[i] = generate.nextInt(n);
  11.         }
  12.     }*/
  13.  
  14.     // the dimensions for the matrix
  15.  
  16.     // Matrix dimensions
  17.     int nRowsMatrixA = 2;  //  number of rows for matrix A
  18.     int nColsMatrixA = 3;  //  number of columns for matrix A
  19.     int nRowsMatrixB = 3;  //  number of rows for matrix B
  20.     int nColsMatrixB = 2;  //  number of columns for matrix B
  21.     int nRowsMatrixC = 2;  //  number of rows for matrix C
  22.     int nColsMatrixC = 2;  //  number of columns for matrix C
  23.  
  24.     double [][] matrixA = new double [nRowsMatrixA][nColsMatrixA];
  25.     double [][] matrixB = new double [nRowsMatrixA][nColsMatrixB];
  26.     double [][] matrixC = new double [nRowsMatrixC][nRowsMatrixC];
  27.  
  28.     Random rand = new Random();
  29.     matrixA [0][0] = rand.nextInt(20);
  30.  
  31.  
  32.     public Matrix multiply (Matrix multiplicand, Matrix multiplier) {
  33.  
  34.  
  35.  
  36. }
  37. }
I am trying to build 2 matrices which when multiplied another matrix with the answer will be displayed. So I cannot compile the program?
Sep 21 '07 #8
JosAH
11,448 Expert 8TB
So I cannot compile the program?
Sure you can; as I wrote: create a project in Eclipse; add a file Matrix.java to it;
add the content (see above) to that file and press ctrl-shift-s. You can't run that
class (yet) because it doesn't have a public static void main(String[] args) method yet.

kind regards,

Jos
Sep 21 '07 #9
Nepomuk
3,112 Expert 2GB
I have this code which is not finished yet and it is not a launcher
Expand|Select|Wrap|Line Numbers
  1. public class Matrix {
  2.  
  3. /*    public static int[] randomIntArray(int length, int n)
  4.     {
  5.         int[] a = new int[length];
  6.         Random generator = new Random();
  7.         // for each item in the list
  8.         (for int i = 0; i < a.length; i++) {
  9.             // create a new random number
  10.             a[i] = generate.nextInt(n);
  11.         }
  12.     }*/
  13.  
  14.     // the dimensions for the matrix
  15.  
  16.     // Matrix dimensions
  17.     int nRowsMatrixA = 2;  //  number of rows for matrix A
  18.     int nColsMatrixA = 3;  //  number of columns for matrix A
  19.     int nRowsMatrixB = 3;  //  number of rows for matrix B
  20.     int nColsMatrixB = 2;  //  number of columns for matrix B
  21.     int nRowsMatrixC = 2;  //  number of rows for matrix C
  22.     int nColsMatrixC = 2;  //  number of columns for matrix C
  23.  
  24.     double [][] matrixA = new double [nRowsMatrixA][nColsMatrixA];
  25.     double [][] matrixB = new double [nRowsMatrixA][nColsMatrixB];
  26.     double [][] matrixC = new double [nRowsMatrixC][nRowsMatrixC];
  27.  
  28.     Random rand = new Random();
  29.     matrixA [0][0] = rand.nextInt(20);
  30.  
  31.  
  32.     public Matrix multiply (Matrix multiplicand, Matrix multiplier) {
  33.     }
  34. }
  35.  
I am trying to build 2 matrices which when multiplied another matrix with the answer will be displayed. So I cannot compile the program?
That class doesn't have a main method, does it? Of course you can't run it then!

If you just want to compile, don't worry - Eclipse is normally set to do that automatically. If it doesn't, check the following:
  • In the task bar, choose "Project"
  • Enable "Build Automatically"
Or just left click on your Project and choose "Build Project".

Greetings,
Nepomuk

PS.: CODE tags are what I used in your quote to make the code look so nice. Just choose the # symbol in the editor when posting your code.
Sep 21 '07 #10
sugard
50
still it didnt work.. dw... i got a big mess where the projects are saved.. dw
Sep 21 '07 #11
Nepomuk
3,112 Expert 2GB
still it didnt work.. dw... i got a big mess where the projects are saved.. dw
What didn't work?
Sep 21 '07 #12
sugard
50
the same window is still popping up with the same error message.
Sep 21 '07 #13
Nepomuk
3,112 Expert 2GB
the same window is still popping up with the same error message.
Do you have a main method now?
Sep 21 '07 #14
JosAH
11,448 Expert 8TB
I'm a bit sick and tired of all those exclamation marks and all that 'urgent' stuff.
I adjusted the topic title.

kind regards,

Jos
Sep 21 '07 #15
Hi,

I was having the same problem with a new install of Eclipse on Ubuntu 7.10 beta.

I was getting an out of memory error as well, and when I didn't get an out of memory error I would get the error the OP was. It stopped after I started running eclipse with these arguments:

Expand|Select|Wrap|Line Numbers
  1. -vmargs -Xmx512m
  2.  
Oct 8 '07 #16

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Mary | last post: by
669 posts views Thread by Xah Lee | last post: by
35 posts views Thread by jeffc226 | last post: by
reply views Thread by Benny | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.