I am using on Xtext to create my own language. My product uses Xtend to generate from my language to Java and I can right click on the generated Java file to run it. But I would like to right click on my own language file and run it directly, then IDE will go to generated Java file to run.
To do that, I have created a command and contribute to context menu.
What should I do next to make IDE goes to Java file and run it?
Thanks
See http://www.eclipse.org/articles/Article-Java-launch/launching-java.html
Related
I have several scala object in my project, sometimes I would like to run one single object whch has no dependency on any other object in the file (just want to see how it would behave before merging it into the whole project), but every time I click on "Run 'XXX'" (where xxx is the name of the object I would like to run, "hello world" for example), intellij tried to build the whole project, actually I just wanted to build and run the single scala object, like "helloword.scala".
I searched a lot and mostly the questions are about Java, if someone wants to run single Java class, then he can right click in the editor zone, then choose the "Run xxx.main()", but in my case ,I just can find the "Run xxx",
someone said that cancel 'make' in run/debug configuration, but how and I didn't find 'make' button in the configuration.
so, anybody have an idea how to compile/build/run just one single scala object/file at one time in intellij?
BTW I am using the intellij idea 2019.1 and the project is based on maven.
Try removing Build action from Before launch section of the corresponding Run/Debug Configuration like so
Edit the Run/Debug Configuration for the Application configuration type
Go to Before launch section
Remove Build action by clicking on the minus - button
You can test this out by creating two apps
// Run.scala file
object Run extends App {
println("woohoo")
}
and
// RunBroken.scala file
obct RunBroken extends App {
ptln("boom")
}
Create run configuration for Run.scala by following above instructions, and it should run despite there being a syntax error in RunBroken.scala.
You can create a Scratch File.
Simply search for Scratch file in the actions search
And search for Scala in the languages dialog: (I'm using Java as an example, since I don't use Scala.)
This will create a new scratch which is accessible under Scratches and Consoles -> Scratches in the Project view.
As you can see here, there are Syntax Errors in a Project file
and yet, the Scratch file will compile and run:
I am just learning Java and use Eclipse. I have a question that I can not find an answer to.
Why does eclipse require me to use a project? I am using eclipse now to learn Java,
and that means compiling my source.
Problem being that when I add another source file Eclipse
compiles both applications. This means (and I could be very wrong here) I need to create a project
for every new program I write.
Why can I not just create and compile programs without a project?
What are you missing is called 'Run Configurations'.
Create a project.
Write your multiple programs within this one project. (Presumably, these programs might share some class files or other resources.)
Each of your programs will contain a class file with an entry point, for example, a main() method.
Open this class file and right-click. Select 'Run As', then the most appropriate option.
Following this you will see your Run Configurations here:
Click the drop-down icon and select the Run Configuration that you want to execute. Select 'Run Configurations...' if you want to add program arguments or making other changes.
I am a novice to the Eclipse IDE and the question is how can I run a Scala project as a Scala application by default? When I run the project by hitting the ⌘R key, it always asks how to run it, as a Scala or Java application. Is there a way to skip this and always run it as Scala by default?
I guess it's somehow related to the launch configuration, but when I try to make a new launch configuration for the project, it doesn't give me the option of Scala: only Java applet and Java application are shown as choices.
I appreciate your help in advance!
Window > Preferences > General > Keys
Scroll down and select Run Scala Application
Edit the Binding to ⌘R or whatever you want.
This changes the binding for your whole workspace, so it doesn't distinguish between Java and Scala applications. It would be nice if the runner had a box you could tick to choose the default, but this is a decent workaround.
I am new to eclipse and wanted to do the following:
Use my custom build commands with eclipse. Until now I only saw make all. I use a shell script for building my project; how can I use that in an Eclipse environment?
When I create a new project with the existing source code, it doesn't add the files, without building the code and if code fails to build (because I generally don't have make all).
How do I resolve this issue?
You can add a custom builder in the "Builders" category of the project properties.
project->properties->builders->new
there you can also deactivate the default eclipse builders..
hope that helped
In addition to what smeg4brains said and assuming that you are using the CDT plugin you can go to:
project -> properties -> C/C++ Build
Uncheck Use default build command on the Builder Settings tab and replace make with e.g. scons.
On the Behaviour tab you can then specify the target to call for the Build and Clean phase.
To resolve your second issue open the Project menu and uncheck Build automatically.
This will prevent Eclipse from building the project when it thinks it is necessary.
If you want to add other your own commands then the easiest way is to write Ant file for your project so by clicking once you can execute all your commands.To see how to write Ant file click here
I was able to do something similar to have protoc run on my .proto files. I did it by adding a "Make Target" to the project.
A lot of stuff in Eclipse you can get around using Ant, which are XML scripts, and there is also a ANT project builder which uses those. If you don't like to mess with frankly quite touchy GUI options, just write a build.xml and use ANT build as the project builder.
After every save I need to right-click on the project in the project browser and click on build.
Is there a way to configure NetBeans to auto-build the project when I save a file?
See Compile on Save FAQ: http://wiki.netbeans.org/FaqCompileOnSave
I don't use CoS myself, I highly recommend Jenkins for your auto-build needs (and so much more): http://jenkins-ci.org/
The compile on save option is not available for free-form projects as of NetBeans version 8.0. And I don't think it will be made available in future too. The very idea of free-form is that that IDE does not know anything about your project and completely relies on the ant-scripts and the mappings you provide.
If you don't want to build an entire project every time you make changes to a file, create a target in ant to compile a single file and map it to the IDE command compile.single. You could add a context menu for that if required, although the existing keyboard shortcut F9 should suffice.
You can read more on the advance free-form configuration here - Advanced Free-Form Project Configuration