Hadoop Create your own program - netbeans

I am new toy Hadoop and i am wondering how to write a program in Netbeans.
The whole idea is to take the source code of word count and then write a new program. The steps i followed are those:
In Netbeans i created a new Class . (SplitData).
Copy- Pasted the entire code of word count and then renamed the class name.
But i have problems in Netbeans. It cannot find the imports.

Hmm, I assumed that you created already the project and then add your SplitData class. In the project tab(in default on your left) you have your created project. Expand it and right-click on the "Librabies" -> "Add JAR/Folder..." and then find the hadoop jar file(in linux a default location /usr/lib/hadoop/hadoop.jar). That's it.

Related

Adding source code to all jars of Tomcat9 Targeted Runtime in Eclipse so that F3 opens source code

In a Dynamic Web Project in Eclipse I have a Tomcat9 attached as a Targeted Runtime (I downloaded binary distribution from official site
But if I press F3 on any class (say, SimpleTagSupport class) no source code appears because it is not attached.
How to add source code?
I understand I can download source code distribution
And I understand how to add source code:
In my case ( SimpleTagSupport ) it is
But can I somehow attach source code to all jars in Tomcat Targeted Runtime? It is a tiresom work to manually find source and attach it to each jar!
Besides I cannot find needed source-folders for all respective jars, b/c source distributions looks like this:
Also it turns out ot be that java/javax/servlet/jsp/tagext folder does not contain any valid source files, but what shall add as source to servlet-api.jar or for javax.servlet.jsp.tagext package (for SimpleTagSupport class)...
The idea is that for every .jar (for example for servlet-api.jar) you specify entire src.zip file (Eclipse will figure out the needed part itself)
Solution is found here
Use: https://javaee.github.io/javaee-spec/javadocs/
If we add source files then besides opening source by F3 it also enables tooltip (javadoc) help (taken from javadocs inside source files) on hover (or F2), but Shift+F2 would not work.
To enable Shift+F2 we need to explicitly attach Javadoc (attach source is not enough for Shift+F2).
Download Tomcat's Full Documentation (not source!!!), unarchive it and then use file:/// notation:
file:/K:/SERVERS/apache-tomcat-9.0.16-fulldocs/tomcat-9.0-doc/servletapi
Now Shift+F2 is enabled!

I cannot create a new Java application in NetBeans 7

I've just installed NetBeans 7.3.1.
I'm just trying to create a new Java application but whenever I go through the wizard it says "Project folder exists and is not empty" and won't go any further. This is a new project so the folder does not exist until NetBeans creates it.
Any ideas?
First thing I'd suggest is to look for any anti-virus in your system that is not letting your NetBeans create any new Project.
You can try :
1 Disabling your anti-virus and try again.
2 Installing IDE in any other Drive except C Drive.
3 One more method but it is bit complex
Step 1: See if you can create a new project in a folder that doesn't
exist yet. Suppose the IDE does make this new folder for you, starts
filling it with files, then stops unexpectedly and says that 'Project
folder already exists, etc'.
Step 2: Look inside the folder and try
to locate the main class for your application (e.g.,
C:\NetBeans_Projects\MyNiftyJavaApp\src\myniftyjavaapp\MyNiftyJavaApp.java)
Step 3: If the main class file does exist but is totally empty (0
bytes in length) it might mean that something prevents the IDE from
filling it with automatically generated code (as happened to me
because of the invalid main class template).
Last thing you could do is upgrading your NetBeans version.

IntelliJ Idea Scala files not available in 'New' context menu

I am new to both IntelliJ and Scala. I am attending the course "Functional Programming Principles in Scala" on Coursera. I downloaded the zip file for the sample assignment, which contained a sample Scala project.
I imported the project successfully (I guess) in IntelliJ. However, when I right-click on a package in the project explorer, there are no Scala-related templates. I can only select "New Java class", XML files and some forms.
Does anyone know why this happens and if there is another way to create a new Scala class or object from a template?
Thanks.
Import the project by selecting its build.sbt file - not the project folder, not the eclipse project file. Then everything is imported correctly.
For me it works as following:
Right clicked on src and selected "mark directory as" -> source root.
This may also be a caching issue.
If so, try File then Invalidate Caches / Restart
Yes, you need to make the scala directory a source directory (in Menu / Project structure / Modules ) but I also had to do the following:
Still in Project Structure goto Global libraries.
Select Scala SDK.
Right click the Scala SDK and Add to module...
Now my context menu gives me New / Scala class and so on.
Once you've created a project and sbt has finished initializing, try creating another project. It should show up correctly in the new project, as it worked for me. It seems to be some kind of caching issue though Invalidate Caches/Restart didn't help me. Also, ensure that source directories are marked properly (source folders appear in blue color, test sources are in green).
I had this problem everytime I created a new project with spaces in the name. eg "Hell Wev". Using "HellWev" as a project name seems to work fine
Same issue (and solution) as #cwadeevans.
A project named "Week 1" did not show Scala files in the context menu "New". The solution was to delete the project and create a new one named "Week1".

How do you configure eclipse to work with a project that wasn't created by it (java)

I have been using the text editor gedit and the terminal for my latest project but I find that I have so many classes it would be more useful to be working with a separate directory for my .class and .java files so I can see what is going on more easily.
Unfortunately I have not been able to figure out how to get eclipse to work with a project that has already been made (or even one that was already made on eclipse with another computer!). This was not such a problem with two or three classes but I am getting to have so many that it is really tedious- It seems to want me to build a completely new project or nothing.
EDIT (additional info):
I don't think it will be possible to show the code of the project as I current have 12 classes for it but by the end I may have one or two more...
I know how to make a project in eclipse. What I am not sure how to do it open a directory full of .java files in eclipse that were created using a text editor rather than in an eclipse project and get eclipse to accept it as a project.
Does anybody know how to achieve this task?
You can import your project into eclipse doing the following steps:
Create a new Java Project in Eclipse (By going to File -> New -> Java Project) select a name for the project and you can select finish
You have to import your existing code to eclipse, go to:
File -> Import -> General -> FileSystem
Then browse to the directory where your code is currently, and say you want to import into the project you created in step 1
Afterwards remember to go to the project properties (right click in the project folder while in the navigator view, for example) and make sure the java build path has the right source folders configured.
Fortunately, you can use eclipse for any project previously created. Do you possibly have the code to show us how you are applying to the project in eclipse?
For example, you can create a project and class, then copy over starting from public static void main(String[] args) {
down to the bottom, then import the important stuff above the main class name.

How To Manually Add Project To Eclipse Without Using Eclipse

I'd like to manually create the folders/files on the file system that create a new project in a workspace in eclipse, and show up in the Project Explorer when eclipse is started and the workspace is selected.
What files would need to be created to do this and where would they need to be?
Please understand that I do not want to open eclipse and make a new project using eclipse. I want to make a new project without using eclipse.
I think you will need to do the following
create a .project file and whatever other files needed by your specific type of project (for example java projects need .classpath) in the project folder, you can find out what you need by looking at those files for another project.
In your workspace .metadata folder, this is where eclipse keeps information about the current workspace, I think the plugin responsible for project definition is .metadata/.plugins/org.eclipse.core.resources , you will need to create those files yourself, some of them are binary, so you will need to open up the source of that plugin to see exactly how it writes them. Depending on your project, you will need to write more .metadata plugin information (for maven for example).
There is no easy way of doing this. Each new project modifies many scattered files throughout the eclipse structure (if you want a list, make a new project and find files created/modified most recently, and/or search for the project name.)
Short of writing the files by hand, there's not much you can do. I found these links in my reseach, but they're both pretty old and seem to be dead ends:
http://www.eclipsezone.com/eclipse/forums/t107019.html
http://dev.eclipse.org/newslists/news.eclipse.tools/msg36546.html
Based on the answers of #shipmaster I think this will work.
Go the workspace and create a new folder as your new required project name.
Copy the contents like .project, .classpath, .includepath etc from any existing project and modify the same like project name, source folder, build folder etc in .project. Do the similar changes in .classpath etc as per the new project requirements.
Unfortunately this is not enough to create a project by just doing eclipse restart so we need to do an import project and point it to this folder and we are ready to use the same now and we see the new project created in eclipse!
try archiving the file .. right click on project ---> export --->archive file(in General section) ..after you archive it as a zip you can import it after.
IF you want to manually copy a pre-existing project to a new workspace,
I have a solution for you:
Copy the project folder.
Paste it into the new work space.
File > Import > General > Existing Project Into Workspace
Eclipse will now see the project you cut+pasted manually.
Why I am doing this:
I am doing this so I can build upon my scrum stories while keeping documentation via working files that each successive step was built upon.
E.g. Story #2 is built upon story#1 code. But I don't want to version them because I want to be able to open them up one after another to do a presentation on my work flow.