Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder Apothem's Avatar
    Join Date
    Mar 2008
    Posts
    380
    Thanks
    36
    Thanked 25 Times in 25 Posts

    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)?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Is this resource jar in a classpath? If not, specify it when calling java by adding the -cp switch. Similar to the javac call.

  • Users who have thanked Fou-Lu for this post:

    Apothem (01-03-2012)

  • #3
    Regular Coder Apothem's Avatar
    Join Date
    Mar 2008
    Posts
    380
    Thanks
    36
    Thanked 25 Times in 25 Posts
    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.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.

  • Users who have thanked Fou-Lu for this post:

    Apothem (01-03-2012)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •