0

I am developing a java application and to run this i am using some command line arguments. These command line arguments are basically a class name and function,and this particular class is in different project.

Is there any way to add this class in classpath of my java project apart from creating its jar and add it in build path.

P.S My IDE is Eclipse.

0

2 Answers 2

2

You can link up two projects at build time.

Right click on your project, Java Build Path, Projects tab and add the project you want to be added to the classpath.

enter image description here

If you want to add command line arguments while running a program from Eclipse, go to Run menu, Run Configurations, select your last run configuration, go to Arguments tab and type in the argument(s) you want and save it.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

If what you want to do is simulate through eclipse the insertion of two command-line-like arguments, you can right-click on Class you need to run (or debug), click "Run (or Debug) Configurations". Now, in Run Configuration Window, just click on the "Arguments" tab: here you can add both comman-line arguments or VM specific options.

5 Comments

I did this problem is to run my main class i gave arguments which is a class and its function class:Debug.testProgram function:topFunction and this class resides in different project and to run my main i should have this class in my classpath of my main java project and i need some mechanism ,apart from creating jars and put in build path, to add this class in my classpath of main java project and one more thing this class is basically a third party class,so wont have any excess to this class(means its jar)
Ok...I am not sure to understand correctly but, if the problem is that the different project where this target class resides is not in your main project classpath, why don't you follow the advice given by @adarshr and link projects dinamically?
are its not the solution to my problem as i told you its a third party jar i can not have it in my build path.suggest me some other solution to add it in my main class project
so the class you're using is in another jar, not in another project??
and i can not put that jar in my build path all the time because as there are so many classes need to b accessed by main class at runtime.so is there any way classpath using command line?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.