-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to run java program in much simpler way #375
Comments
@testforstephen @Eskibear Please take a look at this issue. It should be related to your current work items. |
From @fbricon on August 23, 2018 2:43 While I appreciate the idea of making it easier to run Java apps from the editor, this is out of scope of vscode-java. |
interesting idea. appreciate it. |
@patelkunal I'm working on a task #350 to improve the experience for multiple main classes selection scenario. i suggest you to have a look at that. The brief idea is
|
@testforstephen Cool, it looks like the "active editor" one you are working is exactly targeting to this issue. And from the image, I think whether we can provide a shortcut (e.g. leveraging code lens) to run/debug a mainClass. For me, the "Run" icon looks simple and straightforward indicating the run/debug functionality. |
The experience can be improved up-to some extent with #350 because it still has dropdown selection view. I am suggesting not to have any extra views apart from that annotated main method and all complexities are hidden behind that button/icon and when its clicked just run the particular program (from active editor only) with resolved class path and show output into OUTPUT. I think this gives neat-and-clean experience for running java program. Few question/clarifications -
I am again open for voting for this feature And would love to offer any help - though I am pretty much newbie to javascript or typescript world but can help in anything in java. |
Another challenge for running program with shortcut is how to specify program runtime It probably is enough for most Java programs to only have mainClass and classpaths launch configs. But we still need consider the program with stdin, and program args. Currently these configs must be setted in launch.json. If run/debug the program with annotation shortcut, we need find a good way to prompt these parameters friendly. |
I understand that running program is not straight-forward in all the cases. Lets brainstorm for options suitable for taking configs while running program. Just writing my opinion for handling config cases - please feel free to disagree.
|
yeah, this is doable. Have a quick look at Intellij ux, the run/debug green icon will launch the program only with mainClass and classpaths by default. If there is a debug config with the same Main Class name existed, then use it as the launch config for current program. stdin is not a problem. To support stdin, you just need specify
|
Sounds awesome for accepting feature request. Really appreciate it. I am very much familiar with this feature of Intellij as that's my primary IDE at work. I would love to get involved into development of this and anything else. Please feel free to bug me. |
The annotation ux for VSCode is Not sure whether we can add an icon ▷ in the VSCode gutter area as what Intellij did. @aeschli Is this possible for VSCode? |
Here is the policy to implement the feature.
When constructing debug configuration, search launch.json to find the corresponding debug configuration with the same mainClass and projectName. If it exists, pass it to debugger directly, otherwise, generate a default debug configuration to launch.json. If the user wants to customize the launch options, he/she can change the debug configuration in launch.json.
|
Approach sounds good. While you are doing this, can't it be possible to introduce a keyboard shortcut as well to launch program (either run or debug) as you mention above? Basically launch program (run/debug) from active editor when shortcut key is pressed. Currently F5 does the job by listing all possible programs to launch (Its also very good to see that list LRU manner and active-editor gets precedence) though it would be awesome to just have single shortcut to invoke/launch the program. May be I am asking too much :) |
Quickly run the program through shortcut key is another story, suggest putting it in a new issue and discuss there. Because the shortcut key can be pressed at any time, the context is lost. The active editor could be a non Java file, or a Java file without main method. |
Move the discussion about providing shortcut to launch program to the new issue #431. |
@patelkunal this feature is included in 0.13.0, welcome to have a try. |
Hello. I appreciate this feature, but is there a way to disable it in the settings? |
No setting to disable it yet, but we can consider adding an option to control it. |
Awesome (y) |
From @patelkunal on August 22, 2018 12:40
It would be great functionality to run java main class/program from visual code on click of annotation like Intellij (every main method annotated with nice run green icon). That makes it very easy to just run the java program/main method without any hassle.
Currently debugger-for-java plugin serves the work around by adding entry into launch.json and then select the class from drop-down list (finding it little difficult because I have ten/twenty main method/class inside my workspace). It would be awesome that I can invoke my java program based on context of the main editor with main method annotation. And since this plugin knows the classpath based on either maven/gradle builds, it would be easier to invoke the main method from the annotated icon. Again this is my wish to have it but it would improve developer experience up-to great extent.
Attaching reference images about requested feature
I have also been using vscode for tutoring algos/cs-problem-solving where I am using have multi-modules build with many-many main classes (because its easy to explain the concept rather than worrying about best-practices at that moment). And when I press F5, it gives me long list of dropdown to select my main class which I want to run.
I have also explored code-runner plugin but it just dumb way of typing out command and its difficult to work with classpath and other modules settings. And again I have to maintain commands for all of my main class - why can't that main method can be identified by plugin and get nice annotation to make it easier to run.
Environment
Feel free to mark duplicate if this is already been handled (though couldn't find in issues here).
Thanks in advance,
/kp
Copied from original issue: redhat-developer/vscode-java#615
The text was updated successfully, but these errors were encountered: