Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
Java in General
ClassLoading?
V Bose
Ranch Hand
Posts: 113
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What would be the easiest way to run a
java
class located inside jar file from within a another running java program?
Ben Souther
Sheriff
Posts: 13411
I like...
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Add the jar file to your classpath.
Import the class.
Then instanciate the class and call it's methods.
For example, if I had a jar file (foo.jar) with a foo.bar package.
In this package is a class named Thingy with a method called sayHello().
On Unix:
export CLASSPATH=$CLASSPATH:/jars/foo.jar
or on Windows:
set CLASSPATH=%CLASSPATH%;C:\jars\foo.jar
import foo.bar.Thingy; public class Test{ public static void main(String[] args){ Thingy thingy = new Thingy; System.out.println(thingy.sayHello()); } }
Java API
J2EE API
Servlet Spec
JSP Spec
How to ask a question...
Simple Servlet Examples
jsonf
Is this the real life? Is this just fantasy? Is this a tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
J2EE
WA #2 ..... word association
zipping as self extracting exe
class
c++ or Java--your suggestions please
More...