Eclipse code completion exclusively based on javadocs - java

Is it possible?
I'm developing for a application server that in runtime give me access to some specific classes. I also have the javadocs related to those jars.
Importing all the deployed jar into Eclipse would be much harder than getting auto-completion working exclusively from javadocs.

No, it's not possible. You'll need the binary jars in the eclipse build path to be able to compile your source code.

Related

Communication between Play! project and Java project

Good morning to all.
I have two projects, one as Java Project, and other made with Play!.
Both projects are in Eclipse IDE.
I need to consume a method in Play! project from Java Project.
How can I do that?
Thanks for helping.
I've never used the Play Framework myself, but what you usually do is put the JAR-file you like to use the method from in the "lib" folder in your play project and tell your IDE to add the lib to your java classpath. I'm guessing you're using an IDE to develop your app (would be great if you could mention it in this case).
That should be enough to access the method from the java project and compile your code. I'm not sure if you need to configure the play project to access the lib at runtime.
For more specific help you need to provide more info what you actually want to do and what tools you're using.

Changing Java manifest.mf file and deployment to server

I'm developing an application that should run on a server. The application uses some external jars.
I have build the application and run it on a local machine without a problem.
Now, I need to deploy it on the server. The server has some of the jars located.
What should I do to make my application work on the server, using the jars that are already there?
I don't have much experience with Java, but I understand that there is a manifest file which has a class-path field that points to all the jars needed. Should I change the manifest "manually", so that it points to the location of the jar on the server? What do you do in situations like this, what is the correct procedure?
Also, if I use one version of jar during development, and there is a bit older version of that jar on the server, what should I do to perform the deployment correctly?
And what is the procedure in case of using maven, should I copy the jars from where it locates them on the local drive to one directory, or is there a way for maven to do it itself?
I'm using NetBeans btw.
Thanks
Re "using the jars that are already there":
See Introduction to the Dependency Mechanism, Dependency Scope: "provided ... indicates you expect the JDK or a container to provide the dependency at runtime."
Re "there is a bit older version of that jar on the server":
Update the library on the server or use the older when developing. I'd consider it a really bad idea to use different versions of a library for developing and runtime. This can lead to subtle errors that are hard to identify.
Re "And what is the procedure in case of using maven":
Does the introduction linked above help you in answering this as well?
Maven is supposed to work the same with any type of IDE.

Repackaging the .jar file

I need to add some jars from JRE7 library to my Android project. But for example rt.jar is in conflict with android.jar from Adroid 2.2 SDK, so I get this error:
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
I know there have been several threads about it and things like JarJar, OneJar or FatJar might be good for me. But I don't know how to make any of them work and documentation doesn't really make it clear (for me). I guess they use Ant commands, but I have always used Eclipse built-in builder and now I have no idea how to use neither Ant nor any of mentioned above.
So my question is: how can I repack this rt.jar so I could compile it in my Android project?
Thank you!
EDIT:
Ok, so what I want to achieve is to create a .jar, which can be used during developing Android application (simplifies some functionalities, doesn't really matter). But I would also like to be able to add the very same .jar to standard Java project in order to use some functions there as well. It would look like this:
Whoever writes an application adds this .jar to his Java project -> it enables him to generate certain files (internet is needed to do it) -> these generated files are then added to Android project -> later on, when somebody uses this Android app, these files provide certain functionalities without using internet (off-line).
It would be ill-advised to do this in any project at all, even if it were possible. You would be opening yourself to a wealth of class incompatibility and loading problems. But in any case it doesn't even matter because the core Java libraries are loaded way before your archives are even touched, making any such attempt at overriding them moot.
Not to even talk about the fact that Android is using its own JVM implementation which is not fully compatible with JDK 6 (forget JDK 7). Also note that it may be a copyright violation to package the core Java libraries with your code and could change your licensing options (IANAL).
You need to find another way to resolve whatever issue you are having (which you failed to mention in your question).
There are many JARs that work nicely on both Android and on classic Java. None involve having Android developers pirate rt.jar. Stick to java.* and javax.* classes that exist in both the Android SDK and in whatever level of Java you are supporting, and your JAR will work fine in both environments.
You should ideally refrain from using such .jar files, but if you must, you can add them to build path. But this, at times results in a conflict, like the one that you are facing right now. What you need to do to resolve this kind of a conflict, is:
add the jar in the build path.
Check "referenced libraries". The jar file should appear under the same.
once it features under referenced libraries, check the "android dependencies" virtual directory. If you get to see that you have an instance of the same jar file there as well, you should delete the "android dependencies" folder altogether. (Trust me, this does not affect your project in any way).
having done that, you should be able to compile your code without any further conflicts.
Happy coding.. :)

How can I convert an eclipse-dependent application into an eclipse-independent application?

I developed an application in eclipse that uses many of the classes of the eclipse framework and requires eclipse to run. But now I'm being required to decouple it from eclipse and make it a standalone application. How can I do this?
You might have luck using File / Export... / Java / Runnable Jar File. This will create a standalone .jar file that should be possible to run without Eclipse. You may however need to experiment with the various settings to get it to behave exactly how you want depending on what libraries you are using.
In general however, I'd suggest using a proper build/dependency management tool such as Maven. This will take a bit of time to learn at first, but my experience is that it will make you more productive in the long run....
Start by commenting out the imports for the offending libraries. This will turn red any references to those libraries in your code. Then substitute a different library or refactor your code.
What do you mean by "decouple" it from eclipse? Do you mean you can no longer rely on any of the eclipse libraries, or that you simply don't want it running as a module in the IDE?
If it's the former, you have a lot of rewriting to do.
If it's the latter, then you'll want to basically bundle your module with an "empty" eclipse framework application. This doesn't "unbundle" eclipse, eclipse is still there, but now you don't have any of the IDE modules etc, and instead you have a stand alone ECLIPSE BASED application.
Create a standalone jar file from the Eclipse project as mentioned by Mikera, or you need to re-factor the code such that it doesn't depend on Eclipse libraries.
There is no point in creating a Java application which depends on certain IDEs or platforms. Java code should be independent (which is why it has the power to run on any platform which has JVM installed in it.
Try removing the dependency from your project to the Eclipse libraries. See if you can simulate the same thing using Standard Java libraries. If not, try to create a JAR for your project from Eclipse. If nothing works out, try looking for some 3rd party APIs.

Is there a tool that checks GWT JRE emulation library violations?

I'm trying to port a Swing application to GWT.
However lots of this application classes use things that are not supported by GWT JRE emulation library such as java.util.Locale, java.text.SimpleDateFormat and much more.
Is there a tool that scans a project and spots such problems?
The Google Plugin for Eclipse shows errors for things that are unsupported by GWT's JRE emulation. http://code.google.com/eclipse/
The GWT compiler will complain if you try to access classes in the JRE that are not supported.
My GWT plugin does not warn until the end of a compilation process.
I fixed this issue by the following way.
In eclipse,
Create a java project.
Remove JRE from class path.
Go to gwt-user.jar. Locate java emulation classes. The path is like that: ..super../emul/java/...
Copy them to your java project.
What we get So far, your Java project without JRE have java.lan. and etc. classes.
This will work except com.google.gwt.lang.Array.java will be missing.
I created that array class (you can find it from internet, I couldn't locate it inside jars).
Add gwt-user and dev jars to the classpath.
Now, your own library can use only gwt java emulation and other gwt classes.
Eclipse will automatically warn you if you access a non emulated Java library.

Categories

Resources