...

View Full Version : Running file that includes files from a jar works on Eclipse, not cmd



Apothem
01-03-2012, 08:32 AM
My program is including files from a jar file (imported by using Eclipse). I compiled my program, and everything was fine (in both Eclipse and command line). When I ran the program with Eclipse, everything I expected to happen occurred.

Unfortunately, when I tried to run my program using command line:
java myProg FooBarBaz

I get an error saying that a class my program is using (from the jar file) is not found. What is Eclipse doing so that it my program can run (or to be exact, how can I find out what Eclipse is doing to run my program)?

Fou-Lu
01-03-2012, 02:48 PM
Is this resource jar in a classpath? If not, specify it when calling java by adding the -cp switch. Similar to the javac call.

Apothem
01-03-2012, 07:16 PM
Ah, thanks. I see where I went wrong then. I read about cp while trying to figure out the problem, but for some reason I thought I was only suppose to compile with that argument. Thank you.

Fou-Lu
01-03-2012, 08:00 PM
Ah, thanks. I see where I went wrong then. I read about cp while trying to figure out the problem, but for some reason I thought I was only suppose to compile with that argument. Thank you.

It should be required for both javac and java. With the javac, it needs the resource to be accessible to verify that the code can be compiled with how the resource api was handled. And with the java, its required so it can actually access the linked resource, much like dll's require a system path or the same directory as the exe that is using it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum