Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JView

 
Angel Dobbs-Sciortino
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to run a java program on a Windows XP computer without the JDK. I keep getting an error. This is what I'm typing:
jview -cp . myProgram
I keep getting the error java.lang.NoClassDefFoundError. It's not even running a simple System.out.println("foo") from the first line of the main method. Can anyone tell me what I'm doing wrong?
Angel
[ October 21, 2003: Message edited by: Angel Dobbs-Sciortino ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Microsoft's JVM implements the API defined by a fairly old JDK (1.1.5, I think.) If your program uses anything introduced later than that (and that includes a lot of stuff: Collections, Swing, and lots more) then you'll see this error.
[ October 21, 2003: Message edited by: Ernest Friedman-Hill ]
 
Angel Dobbs-Sciortino
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only objects my program uses are String, StringTokenizer, PrintWriter, BufferedReader, FileReader, and FileWriter. I don't think any of these came after JDK 1.1.
Angel
[ October 21, 2003: Message edited by: Angel Dobbs-Sciortino ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, no, they ought to be OK.
I went over to my wife's XP box and tried this with "Hello, World" and, lo and behold, I got the same error! Now, I'm interested.
So I did a little Googling, and came up with
this link. The upshot of this is that jview reports NoClassDefFoundError if the class file's version number is later than it expects. Since it's so old, it expects quite an old version number, older than any current JDK uses.
To produce class files that jview can handle from a modern JDK, you have to give the "-target 1.1" switch to javac when you compile them:
javac -target 1.1 myProgram.java
I tried this and it indeed works.
Interesting question!
[ October 21, 2003: Message edited by: Ernest Friedman-Hill ]
 
Angel Dobbs-Sciortino
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That worked for me too. Thanks a lot!
Angel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic