I am having trouble importing Alloy libraries to use the API in Eclipse. This is the code I am trying to run: http://alloytools.org/documentation/code/ExampleUsingTheAPI.java.html
The problem is that I am doing something wrong importing the libraries. So this is what I did:
Create a new Java Project (JRE: jdk1.8.0_172) in Eclipse
Right Click in the project > Import > Archive File > select the .jar file org.alloytools.alloy.dist.jar downloaded from https://alloytools.org/download.html
All folders and files are added as in the next picture below.
Create new file in scr folder: ExampleUsingTheAPI.java, with the code from http://alloytools.org/documentation/code/ExampleUsingTheAPI.java.html
The errors displayed are:
Download the jar, right click on your project, select configure build path, click on libraries and add external jar, select your Alloy api and click apply and ok.
If i'm not wrong it should work, i used to do the same when using eclipse.
Related
I've been trying to find a way to attach source into eclipse. I built the spigot.jarand decompiled it into a zip file using JD. Here is the file if you want to take a look at the zip. Now what I'm having trouble doing is attaching the source to a project in eclipse. Yes, I of course have it in my build tools,
but I want to inspect some class' to see if I am using sockets/packets correctly. Here is the picture that eclipse gave me. I've already attached the source to that zip, but it wont work.
Any ideas?
You need to add the built jar file the buildpath of your project. In eclipse just right-click your project, click on "Properties", select "Java Build Path", select the tab Libraries and click on the button "Add External Jar" on the right side. Then choose the Bukkit/Spigot jar file you want to work with and build against on export.
If you need a detailed video tutorial on it:
https://www.youtube.com/watch?v=7dyopdta7ZI
I am making an android app. I have created a java project also that uses BufferedImage to manipulate images. I want to use this project in my android project. How can I do that?
I'm using eclipse. When I right click my android project > properties > android > [add]
my java project isn't in the available options. I think I need to somehow mark it as library.
Does anyone know how I can do this?
Thanks
Add your Java project to your build path:
Right click on your Android project, click on Properties. In the dialog, select Java Build Path, and then click on the Projects tab. There, add your Java project to the build path.
make JAR of your BufferedImage project and then copy it inside your new project, then right click on the JAR in Eclipse and Choose Build Path -> Add to classpath or something like that
I am just trying to compile and run a simple java program. When I go to run my tester class it says select what to run and it gives me Ant Build which when highlighted says "Launches an Ant build with default settings" or Ant Build... that says "Launches an Ant build and allows it to be configured". When I try to select either of these it prompts Build failed. Reason: Unable to find ant file to run. I honestly don't know what these ant builds and files are. This is definitely a dumb question but have no idea what to do.
Make a project to put the files in.
File -> New -> Java Project
Make note of where that project was created (where your "workspace" is)
Move your java files into the src folder which is immediately inside the project's folder.
Find the project INSIDE Eclipse's Package Explorer (Window -> Show View -> Package Explorer)
Double-click on the project, then double-click on the 'src' folder, and finally double-click on one of the java files inside the 'src' folder (they should look familiar!)
Now you can run the files as expected.
Note the hollow 'J' in the image. That indicates that the file is not part of a project.
I was also in the same problem, check your build path in eclipse by Right Click on Project > build path > configure build path
Now check for Excluded Files, it should not have your file specified there by any means or by regex.
Cheers!
right click somewhere on the file or in project explorer and choose 'run as'->'java application'
This worked for me:
Create a new project
Create a class in it
Add erroneous code, let error come
Now go to your project
Go to Problems window
Double click on a error
It starts showing compilation errors in the code.
Your project has to have a builder set for it. If there is not one Eclipse will default to Ant. Which you can use you have to create an Ant build file, which you can Google how to do. It is rather involved though. This is not required to run locally in Eclipse though. If your class is run-able. It looks like yours is, but we can not see all of it.
If you look at your project build path do you have an output folder selected? If you check that folder have the compiled class files been put there? If not the something is not set in Eclpise for it to know to compile. You might check to see if auto build is set for your project.
What I did was I created a new project and opened the file location from my old project and new one. Then I copied everything from the old project besides the run file, and ran it on the new project and now it works fine.
the file is probably located in your project package but is not yet compiled so you are able to open it as a java file in your eclipse java project, here is what I did in my case: in eclipse, goto terminal window, cd to your project directory, then cd to your project package, then run javac yourFileName.java, finally right click your java project or project package in the project explorer and... you should see the file there, and it should now run for you as a java file... hope this helps!!!
Im new to eclipse , can anybody tell me how to use an JAVA API in eclipse. or share any sample Java API.
Yes, how to use JavaDoc file in eclipse.
Yes, how to use JavaDoc file in eclipse.
You can download the Javadoc jar file from the respective project and include it in your build path
Eclipse==> project-->properties-->Java Build Path-->click on the jar file--> edit JavaDoc
Point it to the API URL location/Downloaded Jar file,
Typically, shift + F2 opens the API when the class is focussed upon
Do you mean: how to use a third-party Java library in your Java project in Eclipse?
Right-click your project in the Package Explorer and choose Properties. Go to "Java Build Path". Click "Add JARs" or "Add External JARs" to add the JAR file(s) of the library to your project.
"Add JARs" is for adding JAR files that are in your project directory. "Add External JARs" is for adding JAR files that are not in your project.
Note that the Eclipse help (Help / Help Contents) contains a lot of information, including information on how to work with Java projects in Eclipse and how to add libraries to your Java project.
Here are some nice Eclipse video tutorials . The version of Eclipse is dated ( 3.1 ), but the concepts are still there.
I'm not clear exactly what you're after, but if you create a new Java project, you will have access to the JRE system library's contents as a classpath container.
File->New->Java Project, enter project name, select OK.
You'll then be able to create new classes and access the Java classes.
If you want to reference another jar containing the "API", you can add it to the project's build path.
Say the jar is in the "lib" folder of your project, open the project properties (alt+enter), the Select Java Build Path, then the Libraries tab, select Add JARs..., then browse to the lib folder and select the jar you want to add and select OK.
To attach sources and javadoc to the jar, you can expand the selector in the Libraries tab, click on Source attachment and Edit... and browse to the location of the sources jar/zip, repeat for the Javadoc. The screenshot below shows you the Source attachment option for rt.jar
(source: vogella.de)
and ok back to the workbench.
You should now see that the jar is included on the project's path (the jar has a little overlaid icon on it).
If this is not what you're after, can you rephrase the question?
what you need to do is to hover mouse over some in-built method or class that are using in your program. Hold ctrl on your keyboard and click. Then eclipse asks you to attach source. click on 'attach source', browse for src.zip file after choosing 'EXTRENAL' file. or instead give path for extracted src folder under same ie external file attachment. Next time you hover over an in-built class or method it shows a small description. To view entire javadoc for same, keep holding ctrl and click on it. It worked for me.
I have just started playing with Java, and I really like the language. I am using the NetBeans IDE, and I find one odd oversight. I can create a new class in a project, but NetBeans doesn't appear to support any way to import an existing class into a project.
I manage to get it done by going to some other project where the desired class already occurs, and then I copy/paste it into the source code folder of the new project, then change the package name at the top of the pasted file to match the package name of the new project.
Is there a nice direct way to do this from the NetBeans interface?
Thanks for any help on this.
In the Projects window you can expand the project that you are working on. Right Click on Libraries and select Add Project.... You will get a dialog allowing you to select another Netbeans Project with the Java classes that you wish to use.
You have to just make the .jar file of that/those java files which you want to use in another project.
right click on file->export->java->.jar then finish.
Now you can use these jar into your another project.
When you build the java project in netbeans it creates a jar file on the dist folder in the current project directory.
You can use this jar file for the other project as a package by adding this as ADD jar in the next project.I have tried this ,i am using my old project jar file for new project development.
Use the 'Clean and build' your project option from the netbeans application, that creates the 'dist' folder which you are looking for (and obviously can't find because you havn't cleaned&buld)
The netbeans itself creates .jar files and you can add the jar file to the current project you are working on.