Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-03-2012, 07:32 AM   PM User | #1
Apothem
Regular Coder

 
Apothem's Avatar
 
Join Date: Mar 2008
Posts: 380
Thanks: 36
Thanked 25 Times in 25 Posts
Apothem is an unknown quantity at this point
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)?
Apothem is offline   Reply With Quote
Old 01-03-2012, 01:48 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,659
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Is this resource jar in a classpath? If not, specify it when calling java by adding the -cp switch. Similar to the javac call.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Apothem (01-03-2012)
Old 01-03-2012, 06:16 PM   PM User | #3
Apothem
Regular Coder

 
Apothem's Avatar
 
Join Date: Mar 2008
Posts: 380
Thanks: 36
Thanked 25 Times in 25 Posts
Apothem is an unknown quantity at this point
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.
Apothem is offline   Reply With Quote
Old 01-03-2012, 07:00 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,659
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by Apothem View Post
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.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Apothem (01-03-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:48 PM.


Advertisement
Log in to turn off these ads.