|
Page 1 of 1 |
|
Posted: Mon, 17th Mar 2008 16:55 Post subject: Compiling java |
|
 |
Hey.
I'm building a wiki site and would like to include a wiki extension I've found here.
I know enough about HTML, php etc, to put it together. Unfortunately, I don't know jack about java, but I need to compile those files.
I've installed JDK and managed to compile the MBox.java into a .class file using this command
but when I use the same command on Wp.java, I get this:
Code: | \wikipainting.java:235: cannot find symbol
symbol : class MBox
location : class Wp |
So, can anybody tell me what I need to type into javac in order to compile MBox.class with Wpg.java? Or is it the source code thats causing the errors?
p.s. not homework, honest
Last edited by ZimZimma on Sun, 23rd Mar 2008 18:48; edited 3 times in total
|
|
Back to top |
|
 |
|
Posted: Mon, 17th Mar 2008 22:12 Post subject: |
|
 |
I think it has something to do with the classpath. Check that the java archive (*.jar) is visible when you compile or point the compiler to the *.jar file like "javac -cp \path\to\jar c:\msgbox.java"
hope it helps somehow
rgds
Sabalasa
|
|
Back to top |
|
 |
|
Posted: Mon, 17th Mar 2008 23:20 Post subject: |
|
 |
Thanks for your help. I've done that and got several class files. According to a tute I'm reading, that's major progress.
Thanks again!
EDIT:
sabalasa wrote: | Check that the java archive (*.jar) is visible when you compile or point the compiler to the *.jar file like "javac -cp \path\to\jar c:\msgbox.java"
|
I didn't have any .jar files at that point (I thought that was what I was trying to create?) but this worked:
Code: | javac -cp c:\MsgBox\java -cp c:\wp\MsgBox\java c:\wp\Wikipainting.java |
which resulted in 3 more class files: Wikipainting$1.class Wikipainting$Clock.class and Wikipainting.class
According to Sun's tutorial, this should compile the .class files into a .jar
Code: | jar cf Wikipainting c:\wp\Wikipainting$1.class c:\wp\Wikipainting$Clock.class c:\wp\Wikipainting.class |
This produces Wikipainting.jar, but it says "Failed to load Main-Class manifest attribute from c:\wikipainting.jar"
I've also tried including c:\MsgBox\java\MsgBox.class but get the same error.
I don't expect to be just handed the answer, but can anyone tell me if I'm on the right lines?
|
|
Back to top |
|
 |
|
Posted: Tue, 18th Mar 2008 00:36 Post subject: |
|
 |
I've also found that if I open Wikipainting.java in jGRASP, the applet works fine, but only when the 3 class files are present (Wikipainting$1.class Wikipainting$Clock.class and Wikipainting.class) .
|
|
Back to top |
|
 |
|
Posted: Tue, 18th Mar 2008 08:53 Post subject: |
|
 |
|
|
Back to top |
|
 |
|
Posted: Tue, 18th Mar 2008 18:22 Post subject: |
|
 |
Thanks buddy. I took a look at that, but I think my environment (?) might be the problem.
I decided to start from the beginning, compiling a simple 'HelloWorld' app, found here. It compiled correctly, but when I try to run it, I get:
Code: |
C:\Program Files\Java\jdk1.6.0_05\bin>java c:\mfja\HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: c:\mfja\HelloWorld
Caused by: java.lang.ClassNotFoundException: c:\mfja\HelloWorld
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
|
Could this be because I don't have an IDE installed? I was under the impression that it wasn't always necessary.
|
|
Back to top |
|
 |
Rinze
Site Admin
Posts: 2343
|
Posted: Wed, 19th Mar 2008 00:02 Post subject: |
|
 |
Java doesn't execute a file, but it will try to find a class with the name you specified.
Your class is named HelloWorld, not c:\mfja\HelloWorld
To start you should use a classpath setting, or make sure the current directory contains the class file.
java -cp c:\mfja HelloWorld
or
cd c:\mfja
\program files\java\jdk\java HelloWorld
|
|
Back to top |
|
 |
|
Posted: Wed, 19th Mar 2008 15:59 Post subject: |
|
 |
I FREAKIN DID IT!
Thanks so much for your help. I'd read loads of tutorials, but you two helped me make sense of it.
High-fives for all!
|
|
Back to top |
|
 |
Page 1 of 1 |
All times are GMT + 1 Hour |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group
|
|
 |
|