0

I have got below code snippet after decompiling a java class file. The original class was created in java 1.4. Now I am trying to compile in Java 1.6. I am using eclipse Juno.

Public class[] getClassTypes()
 {
return (new class[] {wt.part.WTPart});
}

But when I compile it I get the error 'wt.part.WTPart can not be resolved to a variable'

When I browse in my eclipse WS, I can see class WTPart is present in my project. Is decompiler has missed something/syntax error?

My understanding from this code is that this method just returns a list of class.

Updte:

    import wt.part.WTPart;
    ...
    ...

Public class[] getClassTypes()
 { WTPart a= new WTPart();
  wt.part.WTPart b= new wt.part.WTPart();

return (new class[] {wt.part.WTPart});
}

I don't get error at the creation of a and b. Only at the return statement I get this error. Thanks

Jagat
  • 61
  • 7
  • `WTPart` is exist, how about `wt`/`part`? – Baby Mar 12 '14 at 05:05
  • One thing I forget to mention that decompiler produced it like 'wt/part/WTPart'. But than I thought that may be I need to replace '/' with '.'. I have linked a external class folder 'Codebase'. Inside this is a wt directory and inside that is a part directory. In the begining of java file an import statement is there 'Import wt.part.WTPart'. There I don't get any compilation error. – Jagat Mar 12 '14 at 05:14
  • if you want to use 'wt.part.WTPart` you need to put package name `wt.part.WTPart` – Baby Mar 12 '14 at 05:17
  • So that means, I need to create a package name 'wt.part.WTPart' and copy these class files inside that. – Jagat Mar 12 '14 at 05:18
  • inside all your class within `part` directory, write this line `package wt.part;` – Baby Mar 12 '14 at 05:21
  • I don't have java file for WTPart. – Jagat Mar 12 '14 at 05:37
  • Actually I am using a lot of class files. These are like libraries. Why I need to create packages foe these files. Why can't I access code from these class files directly. – Jagat Mar 12 '14 at 05:42
  • package is not necessary, but don't use `wt.part.WTPart`, it should only your class name which is `WTPart` – Baby Mar 12 '14 at 05:45
  • Please check that last line is a valid syntax or not in java 1.6 – Jagat Mar 12 '14 at 05:59

1 Answers1

0

You missed the '.class', and the 'class[]' should be upper case : 'Class[]'

return (new Class[] {wt.part.WTPart.class});
Safrain
  • 294
  • 1
  • 5