I want to emulate some Java classes and therefore I use the super-source tag in a gwt.xml module.
I created two eclipse projects one only for the super sources and another which contains the app code.
The super source project has the following structure:
/
/super/Emul.gwt.xml
/super/emul/EmulatedJavaClass.java
Emul.gwt.xml contains:
<super-source path="emul"/>
In eclipse I right clicked on the super folder and added it to the Build Path. That works fine. The problem is that eclipse shows an error on the package tag of my emulated java files.
In my emulated package I cannot use:
<super-source path=""/>
This will give an error while compilation.
Can I do something that Eclipse does not show an error in the package and still have all the nice eclipse features like code completion?
There is no enough info about your complete structure in eclipse, but normally:
Your module.gwt.xml should not be in the super path but in the normal folder for sources, ie: src/com/example/Module.gwt.xml with the entry <super-source path="super"/>
Then you can put your super folder in the src, ie: src/super/com/example/MySuperClass.java
In eclipse you have to configure in your project class path src and src/super, but when configuring src there is an option to put exceptions so set src/super as exception.
Related
I have web application that is running in Jboss container.
Sometime I need to debug the code and for the I need to know from which jar current class is being referred (so that i could search of source jar of the corresponding jar)
Is it possible to get this Jar information (name of the jar file) from which current class is being referred. See the attached screen shot - from where i am trying to get this jar file information. Not sure if my approach is right or wrong
Eclipse allows you to make code changes during debug time.
So, if you want to entering in a class and know what is the jar source of this class just do CTRL + Mouse Right click in the class name and you enter inside the class.
If you have the "Link with Editor" option selected in your Package Explorer you can see automaticly what is ths jar file you are importing.
Compile time classpath settings are different from Runtime server classpath settings.
So if you want to know all the locations/jars that contain a particular class at compile time in eclipse then use Ctrl+T and type the class name. If there are multiple jar files with same class/namespace, then the order will be defined in Build Path settings --> Order and Export.
Runtime reference depends on class loading policy of your server configuration. But usually first it refers from local project, then manifest and then from common class path library.
If your server is configured to refer the workspace location of your project, then most probably the order would be as you defined in .classpath file, and you can use Ctrl+T to find it out.
Edit
It seems you want eclipse to resolve the source file automatically. If you are using maven then run below commands to refresh the source and javadoc for all your jar files.
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc
Eclipse, Android project. I have a library project (mylib) and an app that references it (myapp). I've added to the build path of mylib a folder with a bunch of compiled Java classes (com.foo.*), checked it as exported. Added a call to one of those classes to the main activity. There are no build errors. But when I run myapp and try to call a method from com.foo, I get a "class not found" exception.
When I package the same class folder into a jar file and reference/export that in Eclipse, the app works.
What am I doing wrong? Are class folders not subject to export somehow?
EDIT: here's my thinking. The Java Build Path window treats JAR's and class folders uniformly. Any why shouldn't it - a JAR is, for the most part, just a class folder zipped up. But then there's this discrepancy of behavior when passing classes on to other projects. Unexpected...
You need to make it an android library and import it as such in the android panel
I'm working on a GWT project to which I've built a .jar file to handle some processes, it is however reusable in other projects and therefore I want to keep it as a seperate project. But when I want to run the code in GWT (adding the jar to the build-path) I cannot seem to get it right.
I have added, to the root of my external project a "xxx.gwt.xml" file ("xxx" is the name of the file and gwt.xml the extension) and then I've set the source-path (the -tag to "com.xxx" which is the root of all the packages I access in the GWT program. Then I've made it a .jar, added it to the buildpath of the GWT - project and then also added the source-code to the jar, still it finds the "xxx.gwt.xml" file and then it complains about the import of the "com.xxx.yyy.YYY" and that it cannot resolve the type of "YYY".
Also notice that I'm not calling any methods which contains any libs that aren't allowed in GWT and I'm not getting the warning "non-canonical package" which you usually get when GWT doesn't/can't resolve/whatever something is wrong your package in the -tag.
Thanks in advance!
You also have to define a module in your .jar and then inherit it in your external project.
See http://www.vogella.com/articles/GWT/article.html#modules_use
Every Java project I download has main and test folders. Both contain java and resources sub-folders. Some projects even add more levels: for instance dir1, dir2, dir3 and etc in the root, where each dirX contains src with main and test subfolders. How do I handle them? If I just drop the content of the project root into the default src, Eclipse will attribute classes into dirX.src.main.java.com.pkgY obviously resulting in "The declared package com.pkgY does not match the expected package dirX.src.main.java.com.pkgY" error. Am I supposed to add every dirX/src/java directory as a source separately in buildpath, as this answer suggests? What about the corresponding tests? Thanks.
This structure is Maven's Standard Directory Layout. In your case, you need to add both src/main/java and src/test/java (right click on java folder and go for use this as source folder) and resources as well to classpath through configure buildpath option. Refer this maven link for more details on this.
Make sure you installed m2e (http://download.eclipse.org/technology/m2e/releases), and if you're doing JavaEE stuff with Eclipse WTP, you should also probably add m2eclipse-wtp (https://github.com/sonatype/m2eclipse-wtp/wiki)
Then, you have 2 solutions :
either right click on each project and Configure > Convert to Maven project
remove the projects from your workspace and do an "Import as existing maven project"
m2e will take care of configuring Eclipse based on your pom.xml configuration.
A Visual Studio user struggling w/ Eclipse...
I imported a set of servlets/JSPs into a project in Oracle Workshop for Weblogic. /page.jsp has the following import statement:
import="com.foo.bar.*"
Eclipse is displaying an error:
The import com cannot be resolved.
The class that implements the above import is in /WEB-INF/src but I don't know how to build the class in Eclipse to resolve that error. I assumed Eclipse would automagically build the .java file and place the output in /WEB-INF/classes, but it's not doing that.
It could be that I haven't structured my project directories correctly so perhaps that's why Eclipse isn't building my source. Any suggestions? How can I get this to work?
First of all, /WEB-INF/src is a rather strange place to keep your java sources; you may want to move them out of /WEB-INF (into /src in project root, for example)
Either way, you need to tell Eclipse where your sources are and where you want classes built to. It's done in project properties dialog:
Right-click on your project in Eclipse, select Properties
Click on Java Build path on the left
Click source tab on the right
Click Add Folder button and add your source folder (/WEB-INF/src or wherever you moved it to)
Ensure Allow output folders for source folders is checked below
Under newly added source path select output folder and point it to /WEB-INF/classes or other location of your choice.