CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Java and JSP (http://www.codingforums.com/forumdisplay.php?f=54)
-   -   Running file that includes files from a jar works on Eclipse, not cmd (http://www.codingforums.com/showthread.php?t=247779)

Apothem 01-03-2012 07:32 AM

Running file that includes files from a jar works on Eclipse, not cmd
 
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 01: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 06: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 07:00 PM

Quote:

Originally Posted by Apothem (Post 1176759)
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.


All times are GMT +1. The time now is 05:40 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.