How to import a package from a linked folder resource in a Flash Builder project? - eclipse

I have this folder structure:
/source/MapEditor where the main project resides. (with its src folder inside)
/source/Geonerd with some classes declared as belonging to the Geonerd package.
I've tried to include the Geonerd package, with no luck.
How do I import it? ( the yellow warning icon says Definition Geonerd.Polygon could not be found )
If I copy the Geonerd folder instead, inside the src folder, I can do import Geonerd.* correctly, but not with the linked folder.
Note: it's not a .swc library, it's just the .as sources inside a folder all within the Geonerd package.
Note 2: I added the folder to the project's ActionScript Build Source Path but doesn't work either:
Note that what should be the Geonerd Package is recognized as (default package)
Update: if I make the linked sources belong to the anonymous package, I can import them, but the problem is they have to be in their own package to avoid name clash with other libraries I'm using. And that libraries in turn are also in their own package and I need to import them as well.

You need to add it as an external folder.
Select Project -> Properties -> ActionScript Build Path. On the build path properties page, select the Source Path tab. Click the Add Folder button. Enter or browse to the folder, click OK. The folder is added to the source path.
Should look similar to: http://blogs.adobe.com/airodynamics/files/2012/05/snapshot1.png

Actually I had to add a folder that had a folder inside, named Geonerd so then Flash Builder recognizes it as the Package Geonerd and not just a default package.

Related

Eclipse src folder empty

So for my class I need to use eclipse to do some graphics stuff in Java. I've tried both Eclipse standard 4.4 and Eclipse for Java developers, but with both when I tried to create a new Java project, the src folder is completely empty. Why is that?
Edit: I should add in more information. In the lab section of my class I was able to follow the instructions and create a lab 1 project src folder, which contains many files such as Lab1.java, Polygon1.java and all that. When I am trying to do it on my own machine, it's not working
Because it's a blank canvas!!
Right click on the src file New->Class
Give the new class a name and a package and you're away, you can start coding.
If you want to include libraries create a new lib folder at the same level as the src folder and copy any jar folders into this folder. Right click on the .jar files and click Bukd Path->Add to Build path, you'll now be able to import and classes contained in this jar file(s)!!!
Because you created a new project. If you haven't added any code yet, why would there be code in the src folder?

Eclipse Package Declaration Work Around?

The team in which I'm working doesn't use eclipse and wants the src folder to be setup a certain way. I, on the other hand, am using eclipse. They would like the src folder to have, for example, the following structure: src/main/java/com/* However, they would like package declarations to only have com.* in them. If I go to project->properties and in the source tab remove the src folder as a source folder and then _only add the com.* folder as part of the source_ it will show com.* as a package, but I still have to add the whole path from src down in the .java files. Here's an example of what I have to do in order for eclipse to recognize the packages:
package main.java.com.parser;
And what the team wants is to have main and java just be a folder so the package declaration would just be:
package com.parser;
So although the file structure would still be src/main/java/com/parser, the package name would be as stated in the later example.
Is there a way to do this in eclipse? I've seen some people asking similar questions on here, but they seem to have no concern that the whole path must be part of the package declaration.
I would much prefer not to do this this way, but no one else is using eclipse on this project.
Thanks for any help in advance.
In the Package Explorer, right click the src folder and select Build Path > Remove from Build Path
Then find the src/main/java folder, right click java and select Build Path > Use as Source Folder
Basically this tell eclipse that java is the folder which contains the packages and source files.
P.S. This is a very normal project setup for building with Maven. If you download the m2e (Maven to Eclipse) plugins and choose to create a Maven Project (or import from the pom.xml) then Eclipse will automatically know how to correctly locate the source folder.

Eclipse confusing package to be a folder

I have read some questions on this around here but my tries at the answer have not yielded success. Here is the problem:
Package:com.me.a
Folder(under above package):b
Java class(under above folder):Myclass.java
The proper package structure is com.me.a.b, but eclipse thinks 'b' is a folder. When I right click on b and go to build-source, there is an option that says "use as source folder" which then does something totally unwanted - creates a separate folder with the entire package path as a source folder, and uses a default package:
Folder: com.me.a.b
Package: default package
MyClass.java
How do I solve this annoying issue?
PS: I am unable to use images which to give a better idea but being new here, there is a restriction.
You have project/com/me/a/b set as the source folder. Your build path looks something like this.
You need to set project as the source folder. Your build path will look something like this afterward.
this is very strange. packages are basically folders, so saying that you have package com.me.a with a folder in it named b is essentially the same as having package com.me.a.b.
Or there is something wrong with the Eclipse's workspace metadata for this particular project?
Try creating new project with such package and class in it see if it is any different?
The behavior you describe when choosing "b" as a source folder is expected: you are basically telling eclipse that this folder b is a source folder, a root folder for source java files. this is the default package, every sub-folder of this one is considered a different java package...
I just had this same problem with ONE folder between about 100 folders. The solution turned out to be righ click on the folder (in the package view), choose "Build Path", and then "Include" (Instead of 'use as a source foldre' as the OP did). After that the folder turned into a package.

Why can't Jython find my .jar file?

I have a jar file (not part of the Java standard library) that I want to use.
I've put myJavaPackage.jar into my project directory, and I'm trying to do import myJavaPackage, but I keep getting ImportError: No module named myJavaPackage. What am I doing wrong?
You need to make sure that Jython knows to search your .jar file for modules, which is done using pythonpath. This will differ depending on your setup, but in PyDev:
In the Package Explorer (the tree on the left), right-click on the project and go to Properties.
Select "PyDev - PYTHONPATH" on the left.
Click the "Add zip/jar/egg" button on the right.
Use the directory tree on the left to browse to the folder containing your jar, then click the checkbox next to the .jar file on the right, and click OK, then OK again.
You should also check that the module name you are trying to import matches the package name as specified within the jar file. Note that the jar file might be named differently to the package, especially if there are multiple packages within it.
If you have the source for the .jar, open up the .java file containing the code you wish to utilise, and look for a line near the top that specifies the package. If you find a line that says something like package foo.bar.myJavaPackage;, then you must do one of
import it like import foo.bar.myJavaPackage, and use the contents like obj = foo.bar.myJavaPackage.someClass, or
import it like from foo.bar import myJavaPackage, and use the contents like obj = myJavaPackage.someClass, or
import it like from foo.bar.myJavaPackage import someClass, and use it like obj = myClass, but careful of name collisions using this method.

Using .class methods in Eclipse

I have two classes, Phone.class and Time.class. I would like to use their methods for my project in eclipse, but I cant figure out how to do it successfully. How do you import the .class files so that I can use their methods in eclipse?
Add the folder containing both classes to the build path for the project: right-click on the project in the Package Explorer window and select the Build Path option, then select the Configure Build Path option. The Libraries tab has Add Class Folder and Add External Class Folder options: use the first if the folder with the class files is already part of the project, otherwise use the second. Select the folder and then hit OK and you should be good to go.