By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

error when trying to run the program

P: 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
Share this Question
Share on Google+
15 Replies


10K+
P: 13,264
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
Expert 2.5K+
P: 3,112
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

P: 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
Expert 2.5K+
P: 3,112
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

P: 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

Expert 10K+
P: 11,448
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

P: 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

Expert 10K+
P: 11,448
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
Expert 2.5K+
P: 3,112
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

P: 50
still it didnt work.. dw... i got a big mess where the projects are saved.. dw
Sep 21 '07 #11

Nepomuk
Expert 2.5K+
P: 3,112
still it didnt work.. dw... i got a big mess where the projects are saved.. dw
What didn't work?
Sep 21 '07 #12

P: 50
the same window is still popping up with the same error message.
Sep 21 '07 #13

Nepomuk
Expert 2.5K+
P: 3,112
the same window is still popping up with the same error message.
Do you have a main method now?
Sep 21 '07 #14

Expert 10K+
P: 11,448
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

P: 1
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.