aspose file tools*
The moose likes Beginning Java and the fly likes [newbie] See anything wrong here? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "[newbie] See anything wrong here?" Watch "[newbie] See anything wrong here?" New topic
Author

[newbie] See anything wrong here?

Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

I copied two classes so that I can troubleshoot them by first using the command prompt. Original files were written within Eclipse.

Environment
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)




Output
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:13: ';' expected
if (args.length > 0) _name = args[0]);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:14: 'else' without 'if'
else
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:21: illegal start of type
try
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:21: ';' expected
try
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:27: illegal start of type
if (_modifiers.length() > 0) System.out.print(_modifiers + " ");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:27: <identifier> expected
if (_modifiers.length() > 0) System.out.print(_modifiers + " ");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:27: ';' expected
if (_modifiers.length() > 0) System.out.print(_modifiers + " ");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:27: illegal start of type
if (_modifiers.length() > 0) System.out.print(_modifiers + " ");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:27: <identifier> expected
if (_modifiers.length() > 0) System.out.print(_modifiers + " ");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:27: ';' expected
if (_modifiers.length() > 0) System.out.print(_modifiers + " ");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:27: <identifier> expected
if (_modifiers.length() > 0) System.out.print(_modifiers + " ");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:27: <identifier> expected
if (_modifiers.length() > 0) System.out.print(_modifiers + " ");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:27: ';' expected
if (_modifiers.length() > 0) System.out.print(_modifiers + " ");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:27: illegal start of type
if (_modifiers.length() > 0) System.out.print(_modifiers + " ");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:27: <identifier> expected
if (_modifiers.length() > 0) System.out.print(_modifiers + " ");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:27: ';' expected
if (_modifiers.length() > 0) System.out.print(_modifiers + " ");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:28: illegal start of type
System.out.print("class" + _name);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:28: ';' expected
System.out.print("class" + _name);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:28: invalid method declaration; return type required
System.out.print("class" + _name);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:28: illegal start of type
System.out.print("class" + _name);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:28: ')' expected
System.out.print("class" + _name);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:28: ';' expected
System.out.print("class" + _name);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:28: illegal start of type
System.out.print("class" + _name);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:28: <identifier> expected
System.out.print("class" + _name);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:28: ';' expected
System.out.print("class" + _name);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: illegal start of type
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: <identifier> expected
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: ';' expected
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: illegal start of type
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: <identifier> expected
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: ';' expected
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: illegal start of type
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: <identifier> expected
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: ';' expected
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: illegal start of type
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: ';' expected
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: <identifier> expected
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: illegal start of type
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: ';' expected
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: <identifier> expected
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: illegal start of type
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: ')' expected
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: ';' expected
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: illegal start of type
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:29: ';' expected
if ((_superclass != null) && (_superclass != Object.class)) System.out.print("extends " + _superclass.getName());
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:31: <identifier> expected
System.out.print("\n{n");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:31: illegal start of type
System.out.print("\n{n");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:32: invalid method declaration; return type required
printConstructors(_cl); //see file ReflectionHelper.java
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:32: <identifier> expected
printConstructors(_cl); //see file ReflectionHelper.java
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:33: <identifier> expected
System.out.println();
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:34: invalid method declaration; return type required
printMethods(_cl);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:34: <identifier> expected
printMethods(_cl);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:35: <identifier> expected
System.out.println();
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:36: invalid method declaration; return type required
printFields(_cl);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:36: <identifier> expected
printFields(_cl);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:37: <identifier> expected
System.out.println("}");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:37: illegal start of type
System.out.println("}");
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:40: illegal start of type
catch (ClassNotFoundException e)
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:45: <identifier> expected
System.exit(0);
^
C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:45: illegal start of type
System.exit(0);
^
60 errors

Tool completed with exit code 1


So far I have tried removing the tab characters.

2. I have a small project that is made up of two classes:
ReflectionTest.java
ReflectionHelper.java

If I compile ReflectionTest.java, would it automatically look up the classes called i.e. ReflectionHelper.java. The methods are called statically. Is it required to set the classpath before?


C:\Users\Administrator\Desktop\Java_console>SET CLASSPATH=C:\Users\Administrator
\Desktop\Java_console

C:\Users\Administrator\Desktop\Java_console>echo %CLASSPATH%
C:\Users\Administrator\Desktop\Java_console

C:\Users\Administrator\Desktop\Java_console>javac ReflectionTest.java ??


Jon
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41863
    
  63
There's an extra closing parenthesis in the first line that shows an error.


Ping & DNS - my free Android networking tools app
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18840
    
  40

C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:13: ';' expected
if (args.length > 0) _name = args[0]);
^


You have mismatch parens. The expression is not valid.

C:\Users\Administrator\Desktop\Java_console\ReflectionTest.java:14: 'else' without 'if'
else
^


Well, basically, the previous "if" is already terminated, so having an else here is not valid.

And the rest are probably a chain reaction of errors. I recommend that you fix the first two (or even just the first one), and recompile again.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

Thanks. that was it. Now it only seems to have a problem calling static methods within another class:

Output of command line:
Directory of C:\Users\Administrator\Desktop\Java_console

05/16/2009 01:04 PM <DIR> .
05/16/2009 01:04 PM <DIR> ..
05/08/2009 02:00 PM 41 cleanup.bat
05/11/2009 06:43 PM 1,797 Command Prompt.lnk
05/16/2009 12:53 PM 2,407 ReflectionHelper.class
05/16/2009 12:41 PM 1,945 ReflectionHelper.java
05/16/2009 01:36 PM 1,293 ReflectionTest.java
5 File(s) 7,483 bytes
2 Dir(s) 50,628,554,752 bytes free

C:\Users\Administrator\Desktop\Java_console>SET CLASSPATH="C:\Users\Administrato
r\Desktop\Java_console"

C:\Users\Administrator\Desktop\Java_console>javac ReflectionTest.java
ReflectionTest.java:32: cannot find symbol
symbol : method printConstructors(java.lang.Class)
location: class homenetwork.bkr.training.ReflectionTest
printConstructors(_cl); //see file ReflectionHelper.java
^
ReflectionTest.java:34: cannot find symbol
symbol : method printMethods(java.lang.Class)
location: class homenetwork.bkr.training.ReflectionTest
printMethods(_cl);
^
ReflectionTest.java:36: cannot find symbol
symbol : method printFields(java.lang.Class)
location: class homenetwork.bkr.training.ReflectionTest
printFields(_cl);
^
3 errors

echo %CLASSPATH%
"C:\Users\Administrator\Desktop\Java_console"

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

If printConstructors() and friends are methods in ReflectionHelper, then you need to either say that:

ReflectionHelper.printConstructors(_cl);

or you need to statically import the methods into this class, like

import static ReflectionHelper.*;

Word to the wise: don't blame Eclipse bugs for compiler errors! If your code doesn't compile, there's something wrong with it, not something wrong with Eclipse. Occam's Razor applies here.


[Jess in Action][AskingGoodQuestions]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18840
    
  40

C:\Users\Administrator\Desktop\Java_console>javac ReflectionTest.java
ReflectionTest.java:32: cannot find symbol
symbol : method printConstructors(java.lang.Class)
location: class homenetwork.bkr.training.ReflectionTest
printConstructors(_cl); //see file ReflectionHelper.java
^


You are trying to call the printConstructors() method of your current class -- which doesn't exist. There is no mention of another class, anywhere in that statement.

Henry
Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

Ernest Friedman-Hill wrote:If printConstructors() and friends are methods in ReflectionHelper, then you need to either say that:

ReflectionHelper.printConstructors(_cl);

or you need to statically import the methods into this class, like

import static ReflectionHelper.*;

Word to the wise: don't blame Eclipse bugs for compiler errors! If your code doesn't compile, there's something wrong with it, not something wrong with Eclipse. Occam's Razor applies here.



Thanks...I had forgotten about that

ReflectionHelper.printConstructors(_cl);//works
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18840
    
  40

Word to the wise: don't blame Eclipse bugs for compiler errors! If your code doesn't compile, there's something wrong with it, not something wrong with Eclipse. Occam's Razor applies here.


Yeah... And hopefully, the statement about reporting the bug was a joke. Because it would be pretty embarrassing if it was true...

Henry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [newbie] See anything wrong here?