Java Help

Soldato
Joined
7 Apr 2004
Posts
4,212
Hey,

I've not worked with Java before, and I have a project from 1996 that I really need to get working :(

The source is here

These are the errors I get when trying to compile.

Code:
[jack@tmain Source]$ javac -classpath . -sourcepath . EzStego.java
EzStego.java:26: '.' expected
import ImageEncoder;
                   ^
EzStego.java:26: ';' expected
import ImageEncoder;
                    ^
EzStego.java:27: class, interface, or enum expected
import GifEncoder;
       ^
EzStego.java:28: '.' expected
import EzStegoEncoder;
                     ^
EzStego.java:28: ';' expected
import EzStegoEncoder;
                      ^
EzStego.java:29: class, interface, or enum expected
import DynamicFilterInputStream;
       ^
6 errors

Which come from this code:
Code:
import ImageEncoder;
import GifEncoder;
import EzStegoEncoder;
import DynamicFilterInputStream;

Can't work out why it doesn't like those imports, all their respective .java files are in the same directory, and ive tried compiling them first before the main file.

Anyone have any ideas? I have JDK and JRE installed, im unsure if it's a problem with my compilation environment (/ my lack of Java knowledge :p) or the very dated code :confused:

Thanks,

Jack
 
It's trying to import pagkages you don't have (or haven't created). In EzStego.java comment out:
Code:
import ImageEncoder;
import GifEncoder;
import EzStegoEncoder;
import DynamicFilterInputStream;

In EzStegoEncoder.java comment out:
Code:
import ImageEncoder;
import GifEncoder;
import RGBPaletteSorter;

In GifEncoder.java comment out:
Code:
import ImageEncoder;

And it should compile. If it doesn't, comment out the import lines which are still erroring which I might have missed.
 
Are you using an IDE, If you use eclipse you can get it to import stuff automatically for you when you use it. If you are using external libraries then they should be in your build path. I know on eclipse you can hit CTRL+1 and it will import stuff for you!
 
Thanks a lot, that got it to compile, but I cant get it to execute :(

Code:
[jack@tmain Source]$ java EzStego.class 
Exception in thread "main" java.lang.NoClassDefFoundError: EzStego/class
Caused by: java.lang.ClassNotFoundException: EzStego.class
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: EzStego.class.  Program will exit.

Also tried specifying the class path with no success. Not sure why it cant find the EZStego class, which is defined in EZStego.java :(

I may have to run it with appletviewer rather than java though as it appears to be an applet? That however does nothing:

Code:
[jack@tmain Source]$ appletviewer EzStego.class
[jack@tmain Source]$ appletviewer -debug EzStego.class
Initializing jdb ...
> run
run sun.applet.Main EzStego.class
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
> 
VM Started: 
The application exited

EDIT: gam3r, haven't tried with an IDE yet. Will give Eclipse a try thanks.


EDIT2: All working :D just had to run it with java EzStego without the class extension. Thanks a lot for the help guys.
 
Last edited:
Java's a pain isn't it? :D.

NetBeans is an alternative, I didn't like Eclipse when I last used it (years ago admittedly) but I hear it's better than Netbeans now - an option for you anyway.
 
Pffftt eclipse is the best! Lots of plug-in support! I think your problem is your trying to import something that doesn't exist or you are not specifying the right path.


Edit: Ahh you fixed it :)
 
Go with Eclipse it is very good. Even IBM acknowledge this as their WSAD/RAD or whatever they call it currently is just Eclipse with some Websphere plugins.
 
Eclipse gets my vote too. I use it as my every day development environment. It takes a while to learn the keyboard shortcuts but once you do, you become much more productive.
 
Back
Top Bottom