File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes JView Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JView" Watch "JView" New topic
Author

JView

Angel Dobbs-Sciortino
Ranch Hand

Joined: Sep 10, 2003
Posts: 101
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

Joined: Jul 08, 2003
Posts: 24187
    
  34

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 ]

[Jess in Action][AskingGoodQuestions]
Angel Dobbs-Sciortino
Ranch Hand

Joined: Sep 10, 2003
Posts: 101
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

Joined: Jul 08, 2003
Posts: 24187
    
  34

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

Joined: Sep 10, 2003
Posts: 101
That worked for me too. Thanks a lot!
Angel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JView