How to migrate java code to Jdev12c from eclipseIDE? - java

I want to migrate running java application to Jdev12c. Can i use all the jar used in Eclipse as it is. I have eclipse related jars also i.e.
org.apache.commons.logging-1.0.4.v201101211617.jar
org.eclipse.persistence.core-2.5.0-RC2.jar
org.eclipse.persistence.jpa-2.5.0.jar
org.eclipse.persistence.oracle-2.5.0.jar
can i use these all jars in Jdev directly. and also apache logger file will work in Jdev or not. also do i need to change something in classes and code?
I have folders in the application and which have files. I am also using .property file. so can i directly use this all.

JDeveloper has ability to import code from WAR file or a Maven project (import menu under file menu).
Or you can just create project from existing code.
You'll need to point to the jars in the project properties->libraries and class path

Related

Class not found Exception after exporting Exsisting class to JAR

I have created a web application in java and is working fine. But i want to Convert few classes in JAR format, so that the code inside the jar is not visible to others.
I have totally 5 classes. 3 classes (CreateFile,ProcessFile,HouseWork) belong to a package "FilePackage" remaining two classes are SFTPEngine and ExecEngine they belong to Package "PuttyEngine".
I selected all these classes and gave export as JAR and named it mytool.jar.
Now i deleted all these classes from eclipse and added the jar. In the Eclipse IDE after configuring the BuildPath no error was displayed. when I run the application on tomcat server from the IDE itself I get ClassNotFoundException
How Do I export those classes into a JAR file and use them. These classes use functions from other classes as well. ie SFTPEngine class will access fucntions from others classes and other classes also wil be accesing the functions in SFTPEngine class.
I am not using any build tool. Cause I cannot use them in my office , I need to get permission from admin, so is there any way to do this work without build tools like ANT or MAVEN
In Eclipse, click on your web project / Properties / Tab "Deployment Assembly".
Add your JAR here.
After that, in the server Tab, when you expand the server, then you can expand the web project, and you should see your JAR.
Make sure you include your jar under webapps/ under Tomcat installation directory if you're running Tomcat outside Eclipse.

Netbeans generating .jar file

When I clean and build, Netbeans generates a .jar file for my Java project, and it uses a "lib" folder which has all of my external Jar files that I use. Can I somehow tell Netbeans to package these Jar files into the .jar it makes? So that I can run my project as a stand-alone .jar file?
I am using Netbeans 7.1.1 on Mac OSX
The short answer is no, the long answer is complicated.
Firstly, Java does not support embedded Jars (ie, you cann't simply add the depended Jars into the main Jar).
Secondly, uncompressing all the Jars and merging them into one will overwrite any resources/classes that share the same path/name. This may not be an issue in small projects but is a major issue in large ones (we have this problem with the project I'm working on at work).
One solution is to use something like One-Jar, which basically uses it's own boot class loader to all you to reference Jars inbedded within a single Jar.
I've had issues with this when using our own custom classloader, but otherwise it seems to work well.
It includes Ant support, so you can include it in your projects Ant build script, if you not using Maven, otherwise, you'll need to devise your own build process
There is no options in netbeans to do that.
There are some other options that a quick search would help, but requires manual intervention.

How to explicitly add a piece of code to a java project

I’m working with Net beans IDE and I want to add a piece of code to my project in a way that the source code won’t be visible to the user who is running the project, I decided to export that piece of code as a jar file in eclipse and then add that jar file to the project. But unfortunately net beans does not let me import that. It says which it is expecting a . Or when I insert. It goes in to that class and I cannot import that jar file into the project by import instruction. Is there a command in net beans which creates and object from jar file and then makes access to the functions and classes of the jar file? Would you please give the format of that instruction? If you know a better way to do this task I would be so happy if you share it with me
It's not that Netbeans doesn't let you import the classes but it cannot find the classes you want to import. You should first add the dependency jar file to your Netbeans classpath.
I assume that you are building an Ant project. For a downstream project, right click on the project in project browser then choose Properties menu from popup menu. Select Libraries node from the catagories box. You can now add jar file to your project using the add jar file button on the right.
However, I recommend you to have a look at building your project using maven. You can configure the dependencies using xml. Having said that, you should use whatever you are the most comfortable with.
P.S.
It's "Netbeans", not "Net beans".
You can build a jar file using Netbeans. You don't have to go all the way to Eclipse just to build a jar file.

Can I grails project have java code in it, or you have to import?

with a grails project, do you put java code inside the same project or do you have to somehow import the java libraries you created from another java project?
I put any java source in the src/java directory and it gets automatically compiled when I run the app. When I have jar files with out associated code such as third party libraries or librarys from another group in the company I just drop them in the lib directory and grails automatically allows you to use them.
Both alternatives you mention work fine. IIRC, Grails even automatically creates a "java" source folder for your Java classes.
In addition, if you use Maven for the Java project, you can set pom=true in the BuildConfig.groovy file and create a dependency on the original JAR; it will get pulled in with each build.

How to build a Java Servlet in Eclipse?

I'm new to Java. I have to modify this Web Servlet that is running on my Tomcat. The Webapps folder contains several files and directories, but only one .JAR file. I managed to decompile it using Java Decompiler JD-GUI, but when I create the project in Eclipse from the decompiled source and try to Validate it, Eclipse shows me around 389 errors. Errors like
HttpServlet cannot be resolved to a type
And I don't even know which Eclipse button rebuilds the .JAR file. Can anyone help me?
Your eclipse project will need to include the libraries that the servlet relies on to work.
If you create the Eclipse project as a Dynamic Web Project it will set up some of the basic structure needed, including the relevant libraries. You may need to include other libraries if the original code relies on them, but from your description it seems fairly unlikely.
You can create a JAR file from the Eclipse File Menu. click Export..., and select Java->Jar file.
Many projects will use ANT which allows you to define scripts to perform tasks needed to compile, package, deploy and test a project.
you create the Eclipse project as a Dynamic Web Project it will set up some of the basic structure needed, including the relevant libraries. You may need to include other libraries if the original code relies on them,
create a JAR file from the Eclipse
File Menu
click Export..., and select Java->Jar
file.

Categories