Eclipse open console apps in separate window - java

Is there a way to configure eclipse to open console apps in a new window rather than it's own console when you run/debug them?
I'm debugging a client/server application and I'd like to see the output of both apps at once and not have to switch between the tabs...

In eclipse, you can have two console views...
On the console view, you have a button called 'open console' (the most right button in the console view). If you click this and select option 3 (new console view), you will see two consoles.
If you right click on the console tab and click on 'detached' the console will be detached from the eclipse frame. (for Eclipse Juno, see the HRJ's comment below)
You can select which output you want to see on each console by clicking the 'display selected console' button (second button from the right on the console view)

I have a different solution to this that works for my situation, and can probably be adapted by others.
I actually want a real second console window -- gnome-terminal in my case. I want this because I want ANSI color support and I want JLine to operate correctly. I can separately start my program and connect remotely for debugging, but that's annoying.
Locate where Java runs from, for the JRE eclipse will run as part of your debug config. Create a script there named gjava, give it the following content, and set it executable:
#!/bin/sh
gnome-terminal -x java $*
Then, in your launch configuration, on the common page, uncheck "Allocate console". On the JRE page, under Java executable, choose "Alternate" and enter gjava.
When Eclipse launches in debug mode, it will launch a gnome terminal and pass the remaining args to the Java processor, which will be running inside its window.
At that point you have a real console that supports JLine, ANSI colors, and full debug support.

When you create the second console, click on "Pin Console" and this will keep the console attached to the last application it was used for.

This is an old question, but I ran across this - and in my case, I have a Python program that I want to run in a separate DOS window.
My solution was to create a run configuration for CMD.exe under "External Tools".
I opened Run > External Tools > External Tools Configurations...
I right-clicked on Program (on the left) and picked New Configuration and named it "RunFooUnderCMD" (Foo being my project)
Under "Location" I put C:\Windows\System32\cmd.exe
Under "Working Directory" I put ${workspace_loc:Foo/}
Under "Arguments" I put the following all on one line:
/c start cmd /c python -u ${workspace_loc:Foo/path/to/startup.py}
(note that I used forward-slashes even though it is Windows)
and clicked "Apply" and "Close".
Voila! I can navigate to "Run > External Tools > 1 RunFooUnderCMD" and run my program.
Eclipse also automagically provides further menu shortcuts; exploring those are left as an exercise to the reader. :-)

Related

cannot open jar file by double clicking on macOS

I created an executable jar with intellij and ran it fine via the terminal, however whenever I try clicking on the jar inorder to run it I get a message:
The Java JAR file "mazegame.jar" could not be launched. Check the Console for possible error or messages.
And this is somehow exclusive to my mac system, on windows it works fine. I have the java launcher set as default, so I don't see why it should not work.
would appreciate any help with this.
While coursing the item for example program.jar:
Double click and open list of options that can be used
press option > choose open
Then you can open it

Libgdx stuck generating an app

When I click on the downloaded libgdx file I select run with Java then the libgdx window pops up I check android (and tried to check desktop too) and leave the names default and some times I tried to change them and for extensions I leave it as default the only one checked is box 2D.
Its says in the little console below that it's generating an app in my desired path then its just stuck there for hours.
(I checked task manager and its not using almost any resources other than 60 mbs of ram)
This problem could possibly happen if the application cannot write into the destination folder you choose. So avoid making the destination folder inside the system32 folder or such.
Run the jar file from the command prompt to see the exception it generates which should explain the problem:
Hold down the Windows button and tap the 'r' key.
In the dialog type 'cmd' then enter.
Copy this text using ctrl-c, include all quotes. Adjust the file names to point to your Java VM runtime and your downloaded
gdx-setup.jar file: "C:\Program
Files\AdoptOpenJDK\jdk-8.0.222.10-hotspot\bin\java.exe" -jar "C:\Users\keith\Downloads\gdx-setup.jar"
Paste the text into the command prompt by pressing ctrl-insert (the zero key on the numpad). Alternatively, tap the top left icon,
then edit, then paste.
See what the specific exception is in the cmd console when the gdx setup program runs.

How to set Run Configuration and Debug Configuration in Eclipse to choose the class that has the main method as the start-up class?

I am using Eclipse for Java EE, Mars 2.
I have two classes in my Java (Swing application) project:
Program.java (has the main method)
Foo.java
If I right-click the editor while Program.java is open, the context-menu presents the commands Java Application and Run Configurations under the Run As menu.
The same happens if I right-click the editor surface while Program.java is open and choose Debug As from the context-menu. I see the two sub-menu items namely, Java Application and Debug Configurations.
However, when I have Foo.java open, right-clicking the editor surface presents only one sub-menu item named Run Configurations or Debug Configurations upon choosing Run As or Debug As respectively.
So, every time I want to run my project and I accidentally right-click the editor surface area while Foo.java is open, I then have to go to the editor tab that has Program.java open and right-click again and choose the right menu item.
I am suspecting there is a way in the Run Configurations and Debug Configurations dialog boxes to tell Eclipse to choose the Program.java class to run as the start-up class since it has the main method.
How do I do that?
You should turn to "Project->Properties" and then select "Run/Debug Settings". There you should be able to configure your project so that it always "runs" the same.
Alternatively, some workaround that I often use when doing JUnit testing on different classes: on top of your eclipse window, there are these buttons
The pulldown icon there opens a "history" of your last run/debug/... "runs". So, once you got your program "run"; you can just use that history to invoke it.
Right click on Foo.java and in Run Configurations dialog, add main class, like below :
Another Solution is setting your launching configuration in window -> preferences
and you can run your project using F11 key (or any key that you can config) i

Launch4J executable not executing as expected

Tools: Win 7, Launch4J 3.5, Simple Hello world Java console app (bundled in a JAR file)
Hello all,
I have a basic JAVA console application that doesn't request any inputs, just a simple application that opens a console window and displays Hello World text.
I built it so simple so I can experiment with Launch4J 3.5 and build an executable file from the jar file.
Everything looks fine, the exe builds successfully but when I launch it nothing happens, I get the hour glass for a few seconds then nothing. I check the Task Manager and there's no process stuck in there.
See my settings in Launch4J, I only filled in the basics, I tried with and without an entry in the Wrapper manifest field:
Output file: C:\Development\SFDC\ProjectX\out\exe\ProjectX.exe
Jar: C:\Development\SFDC\ProjectX\out\artifacts\ProjectX_jar\ProjectX.jar
Wrapper manifest: C:\Launch4j\manifest\uac.exe.manifest (also tried with leaving this blank)
The rest is all left as default.
If by launching you mean double clicking it, no - nothing you can see will happen; you have to 'tell' Java to run your application with an associated console. To do this, you may create a new .bat file: Simply open a text editor and insert the following line:
java -jar NAME.jar
where "NAME" is the name of your application. Save the text file in .bat format, not in .txt, and place it in the same directory as your application. You can launch your application by double-clicking that file.
The reason it does not pop up in your task manager is because probably (I cannot know) your application only prints out a simple message and does nothing more. In non-console mode, it will just call your print (println or any other console) method without having any visual effect as there is no console to print the message to. In both cases however, if you only print something and do not perform other operations that 'last', such as listening for input, your programm will terminate as it has reached the end of the main method.
Yes. You do need to use the console mode.
You also do need to have some method of keeping the console window open, because it closes the console the moment the program terminates. Use scan.nextLine(); or Thread.sleep(i) if you really need to.
Possibly you need to use launch4j in console mode, see this answer: lauch4j hello world program

Run my java app (System Tray) when Windows starts

I have searched on the net, but I have not found anything for my case.
I have created an application, that shows only in the SystemTray (icon) when you start. I want to run the jar file or the exe automatically when windows starts.
I would like to do this via code or automatically directly from my app. A menu item (for example) that the user could click on that option, if desired. I searched the internet but have not found anything.
Thank you in advance
Thank you very much
Only code Java or Bat
I think you can register your application as a system service, set the starttype auto start
Follow the below steps for windows 7
1)Click the Start windows button , click All Programs, right-click the Startup folder, and then click Open.
2) Open the location that contains the item you want to create a shortcut to.
3) Right-click the item, and then click Create Shortcut. The new shortcut appears in the same location as the original item.
4) Drag the shortcut into the Startup folder.
The next time you start Windows, the program will run automatically.
I got from this link

Categories