Getting a Class from another project programatically - java

I want to access a class which is present in another project . For that i use java reflections,but first i need to get the class object which is in another project.I want to get it programatically.I can do that like right click on my project then go to build configure path and then to project tab and add project.I want to do it programmatically .How can i do that?Help

You need a custom class loader.
tutorial link1
tutorial link 2

I think you can do it by creating a jar of the dependent project and adding it to class path before you run your application.

It seams you are working in eclipse and want do use the classes from projet B in projet A, is it so?
If so you could specify in eclipse that project A depends from project B by adding the project in the 'java build properties'.
Do get the right answer, you ask to be more specific in your question like Steven wrote.

Related

How to get project name as a variable in intellij to use for XML files?

Simple problem:
I wanna build my project and have it automatically be named after my project-directory.
Any clean way on how I can get my project name as a variable?
Thanks in advance
As described in docs https://www.jetbrains.com/help/idea/absolute-path-variables.html
in IntelliJ IDEA, there are some pre-defined variables.
It seems you could work around this one
$PROJECT_DIR$ - stands for the directory where your project is stored.

How to add project to Create Project Wizard in Eclipse

In Eclipse while creating new project, the following window opens (consider the area surrounded by red lines in the image).
From that we can select project as Java Project or as per our requirement.
Now my question is, is it possible to add Custom Java Project as a project template in select Project Wizard ? If yes, how?
I want to create (please look the area surrounded by black lines in the image) a project having the name IoTSuiteSpecification as a default Project template in Select Project Wizard with mentioned four files and package.
For example, while creating new project, IoTSuiteSpecification is there in Select Project Wizard. Let me know if you need more clarity.
As you did not provide detail about what function you want to implement. This answer will just focus on how to create a new project wizard, but not the functionality details.
In short: you need to write a plugin and install that on every Eclipse you want to have this function.
I would like to keep this answer short, so the following content assumes you have basic knowledge about Eclipse Plugin Development, and have already created a plugin project. If not, please refer to tutorials such as Your First Plugin or Google "Eclipse Plug-in Tutorial".
Step 1: Create an extension for your project wizard
Go to plugin.xml -> Extensions -> Add -> org.eclipse.ui.newWizards, choose the "New File Wizard" template, click next.
Name your Classes properly. I will call everything NewWizard. So the wizard class is NewWizard, and the wizard page class is NewWizardPage, etc. Do not care about the "File Extension" and "Initial File Name", we won't need them.
Click Finish
Step 2: Implement the classes
After the previous step, you will have a package containing the wizard classes you just created. It should have two classes NewWizard and NewWizardPage.
First, you need to customize NewWizardPage to provide controls for your user to specify information such as Project name, etc. Refer to org.eclipse.ui.dialogs.WizardNewProjectCreationPage for an example of how to create a new Project Wizard page.
When you gather information from user, you should do some setup of your new project. Open class NewWizard, and find the function performFinish. In this function you should create your new project and setup it such as adding project natures. org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard is the eclipse wizard for creating a new general project. It provides a good reference for how to do these. If you have no idea, read or just copy their code.
Step 3
That's it! Enjoy your new project wizard!
Examples
As an example, you can look at my project https://github.com/harperjiang/TeXDojo. This is a plugin I wrote for Eclipse to edit and compile latex files. It contains a complete project wizard implementation in the package LaTeXEditorPlugin/src/hao.tex.dojo.latexeditor.wizards

netbeans build project error

i am new in java and i am a student, I am using net beans 8.0 for java developing i created a project and run it using Shift+F6, it is working fine, but when i go for build project from the project categories then in the "Browse Java FX Application Classes" window nothing display in "available classes" so therefore i can't build my project. Moreover the dist folder also not exist in my project.
Please let me know how to resolve this problem where i am wrong or which option i miss.
Thanks in advance.
It needs to find the class that extends Application. You can right click the project in the project window the choose properties then run. You will see a box for Application class. You should be able to select the class there.
If there's nothing in the 'select classes' box then maybe you forgot to declare the class like
public class JavaFXApp extends Application {
//etc..

Can't find string resources from another project

I have an Android project let's call it SimpleProject in that project I get strings in this way getString(R.string.error) I keep all my strings in the projects /res/values/strings.xml. Besides SimpleProject is not a library project. Now I add my SimpleProject src folder as a linked resource to another project lets call it TestProject and then I try to build my TestProject Eclipse give me error that he can't find R.string.error. What can I do to solve this problem ?
EDITED:
I think about following issue
If I change all my applications packages to the same for example com.android.victor in that case all R-s will be same com.android.victor.R and if I add one project to another it will not bring to that that R will not be found. Am I right ? and what problems can appear in this case ?
I think you need to change the order,
1.go to Java Build Path
2.go to Order and Export and move the SimpleProject reference to be above the TestProject folders

How to build 4 projects(example) and make them access each other?

How do I make something like 4 project and make them see each other, like a .xhtml to a Bean and a Bean to the interface that implements the method to save or read something from the database?
The other solution would be to:
use only one workspace (meaning each components see each other)
define task context with Mylyn in order to switch from one component to another and see only what you need.
You cannot split workspace. You can create as many workspaces as you want and add there as many projects as you want. To create new workspace just create directory and then start eclipse and give it this directory as a workspace. It will do everything automatically.
Unfortunately your second question is unclear.
Right-click on the project; choose Properties. Click on Project References and select the other projects.

Categories