How do I export a Java application in Eclipse? - java

In Netbeans a simple click to clean/build creates a nice folder called dist/ in the project workspace and contains a runnable .jar, all in the background no repetitive popup menu.
Is there some sort of setting in Eclipse to make this same process faster and easier, even a hotkey to direct export using previously set settings would work?

It's not particularly hard in eclipse.
Right click on the project name and select export.
Open the Java section and select "Runnable Jar File", click "Next"
Fill out the supplied form with the appropriate options.
That's about it.

Related

Running Java file in IntelliJ

I need some help with IntelliJ. I am fairly new to programming, and I have some experience with the IDE but I am by no means a know-it-all when it comes to IntelliJ.
I have 3 Java files (without their respective class files). When I open intelliJ it asks me:
Create New Project
Import Project
Open
Check out from Version Control
I click on open, IntelliJ opens up a file location, I click on one of the three Java files to open, and I drag the other two one by one (they open in their separate tab).
I cannot figure out how to run them. It is likely that I need to create run configuration and I don't know how to do it. I know how to create a new project and get everything working, but I don't know how I can get the files working if I just open them. Can someone tell me how to create the run configurations to run the files? Please and thank you.
IntelliJ IDEA is a great IDE!
This is what I would do:
Select File/New/Project... in the menu. You will get a new modal window.
Then select Java on the left, make sure that you have your JDK selected (top right), it not there, create it right from the window. Click 'Next'.
Just go 'Next' on the 'create project from template' step.
Then type your project name and select a folder for it. It will create a new project.
After that, copy your java files into /src folder using drag-and-drop in IDEA or just a file manager you like.
Now you have an IDEA project with your source code in it. You might need to sync your IDEA project, use File/Synchronize for that.
Finally, you can right click on you java file and 'Run' it from IDEA.
It the project fails on compilation you might need to add required imports and libraries, but that depends on your code. IDEA will highlight all the errors.

Intelli-J: cannot create class-file?

This is honestly a tiny problem but it's keeping me from proceeding with my small Java practice app.
I'm currently practicing making an API call in Java. I was trying to create a simple class file called "Film". However, when I try to create it as a class-file, Intelli-J keeps telling me that it is unable to create a class-file. I'm trying to set this file up in a folder called "models". All of these class files are going to be utilized as part of an app that performs API calls.
Is there some naming convention I haven't followed? I've been Googling but haven't really found anything.
More directly, based on what #Vishal Jumani touched on, you need to tell IntelliJ what directories are 'source' or 'test' directories.
A directory structure you can use as an example, but you can use whatever you wish.
Right click on the directory you wish to mark as 'root' --> find 'Mark Directory As' --> Select 'Sources Root'
Now you should be able to add java classes in the directory without IntelliJ interrupting you!
This would usually be because of the way your project is setup. It may not be setup correctly to indicate where your source code is.
To setup your project, in the Project Tab, click on the top most folder and select F4. This should bring up the Project Settings dialog window.
Now click on Modules in the LHS, and then select the Sources Tab on the RHS
Select your src folder and click on the Sources button, to indicate this is your source folder. Now IntelliJ is aware that this is where your code is.
Click on Apply and OK. This should close the Dialog Window.
Now right click on the src folder and then select New -> Java Class to create your Java class

How to convert source and class files into 1 executable for an applet?

I have finished a project - jave applet - for a friend. To run the project I am simply clicking Run Application within eclipse. How do I convert my project into 1 file, such that my friend can simply open that one file and the applet will start?
just export your project as a jar, either directly through eclipse or by using something like Ant.
Then your friend just puts the following code in their html...
<applet code="yourMainClass.class" archive="yourArchive.jar" codebase="yourCodebase/">
To reiterate, you create a Jar file which is done in Eclipse using the Export wizard. Press the File menu then the Export sub-menu, then follow the instructions:
Select Jar them Next
Select the needed files and resources, create a Jar file name, then press Next
Select options, then Next
Select a main class -- I know this is important for a desktop application, but I'm not sure if it's needed for applets.
The easiest way is to use eclipse export option.
Go to File->Export->Java (from list) -> Runnable JAR File (if you dont have it use JAR File instead)->Choose the project you want -> Choose Destination folder -> Finish.
In the folder you have choosen, will be a .jar file.

Netbeans - how do I find the path to a file within this IDE?

I want to be able to right click an item within the 'Projects' or 'Files' window, and either have an 'open in file system' option, or 'copy absolute path to this file'.
Is there a plugin or a hidden option within Netbeans that will allow me to achieve this?
I just need an easier way to get to the folder within Windows Explorer without having to spend the time navigating there.
I'm open to making a small plugin myself if it'll make it happen?
With Netbeans 8 you can use:
Alt+Shift+L
It's defined under Options->Keymap as Copy File Path(s)
Somewhat related : netbeans - how to view file full path in window title (or somewhere else)?
You can use either of following :
Use Alt+Shift+O to open files by name (which shows the path and the
project)
Hit Ctrl+Shift+1 while in the editor to highlight the file in the
Projects View
There is a community contributed plugin on NetBeans bug-tracking system that can implement the feature. I have verified that the plugin works well with NetBeans 6.9.1. Once installed, you could copy the path of a file (or files under a folder node) via Edit/Copy Path menu.
Plugin "Path Tools" # plugins.netbeans.org
I use this plugin which lets you copy the full path of a file to the clipboard - https://github.com/kinkadzs/QuickOpener-NetBeans
The information you search can be accessed trough the file properties.
In the Projects window, right click on a file, select 'Properties', the file path is under the 'All Files' line.
You can also press Alt-Shift-O while the file is selected in the Projects view or the file you're editing.

How to reuse eclipse launch file in a new project

I just checked out an svn project in eclipse as a java project. There is are couple of run launch files in it that i want to reuse but dont know how to point 'Run' to see those launch files or use it. Any tip? thanks
Usually these are automatically picked up by the project and placed in the run menu. If they are not, Right click on the .launch file then choose 'Run As' and select the first option. This will run using that run configuration.

Categories

Resources