Could Not find the Main class.Program Will exit - m2eclipse

this is NaveenKumar from Banglore here my problem is i tried to run the java programs in Eclipse Id in my machine but when i was tried to run my java program in Eclipse Id, then it is displaying a Error Dialog Box jest like as "Could Not find the Main class.Program will exit, like wise it is displaying. For this what to do please provide me the your valauble answers to my mail....

You have a class which has a public main() method?
Select the class in the Package Explorer, rightClick -> Run As Java Application
That should be all you need.

Related

In a Kotlin multi-platform (or JS) project, (how) can one pass custom command line arguments to Node.js?

I'm working on a Kotlin multi-platform project, and I need my JS tests to run on Node.js but with custom command line arguments (specifically I need node to run with the --expose-gc flag, because some tests need to trigger garbage collection).
Looking at the documentation for the Gradle Kotlin JS DSL I didn't find any mention of how to do that; does anyone know whether it's at all possible and how?
Unfortunately can not answer your question directly, but there is some suggestion to help you with reverse engineering.
Let's start from some example. We have Gradle tasks to run our project using webpack's dev server such as browserDevelopmentRun, browserProductionRun (not sure if multi-platform projects have it, but JS projects do). We can add:
println(tasks.named("browserProductionRun").get().javaClass)
to build.gradle.kts to find out the exact class used for this task. When we sync Gradle, it outputs:
org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack_Decorated
Now we know the exact class of this task so we can investigate its API. The auto completion or navigating inside of the KotlinWebpack class helps us to find out that it has a helpful nodeArgs property to configure NodeJS arguments for it, so we can set them, for example:
tasks.named("browserProductionRun", org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack::class).get().nodeArgs.add("--trace-deprecation")
Getting back to your question.
In your case I guess you need to investigate the browserTest task. Let's get some info about it by adding:
println(tasks.named("browserTest").get().javaClass)
to build.gradle.kts - a-ha - it seems to be of the org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest_Decorated type. Let's check what's inside. Open KotlinJsTest.kt somehow - for example by typing its name into the window being opened by CMD + Shift + O (make sure to select "All Places" here) or just by typing its name somewhere in build.gradle.kts and navigating inside it.
The only interesting thing I see inside this open class is the following block:
override fun createTestExecutionSpec(): TCServiceMessagesTestExecutionSpec {
val forkOptions = DefaultProcessForkOptions(fileResolver)
forkOptions.workingDir = npmProject.dir
forkOptions.executable = nodeJs.requireConfigured().nodeExecutable
val nodeJsArgs = mutableListOf<String>()
return testFramework!!.createTestExecutionSpec(
task = this,
forkOptions = forkOptions,
nodeJsArgs = nodeJsArgs,
debug = debug
)
}
So maybe it can work out to create your own extension of this class, override its createTestExecutionSpec method and provide nodeJsArgs as you need inside it. After that you'll be needing to declare another Gradle task to launch tests inside build.gradle.kts which will use this new extended class.

how to run Groovy script in Netbeans?

I'm trying out NetBeans for editing Groovy code. (I'm new to Groovy, and it's been a long time since I did any Java development).
At some point I installed the Groovy plugin via the "plugins" tool. But it does not have the green checkmark under "active", and choosing the Groovy plugin does not make the Activate/Deactivate/Uninstall buttons available. Oh well...
So let's create a project...
Choose "new project". I'm choosing "Java with Maven" just because it's the first one.
Hit "Finish"...and voila, I have a project.
Let's create a file...
Right click the project package in the left pane, choose "new"
Choose "Groovy Script" for a type, hit "finish"
Hey, I have a very simple script. Looks like it should say "Hello chris!" when done.
Hit the "play" button on the toolbar....things appear in the output window.
But wait a minute...the output is "Hello World!", and it should be "Hello chris!" It looks like "HelloWorld" is coming out of "Mavenproject1.java".
How can I (or can I) just run my script from within NetBeans?
UPDATE: per #andrewJames suggestion, I tried working that tutorial. (It looks like the tutorial may be a bit out of date.)
I created a "Java Ant" project, as that was the only one that offered me the option of not creating a "Main Class File".
I created the Java form, and the Groovy class, as directed.
When I run the project, I get an error message saying "Error running forked groovyc".
I get that same error whether I'm running on a machine with a groovyc executable or not, so I suspect that there's something about the configuration that I need to change in order to point to the groovyc executable.
Probably something to do with the build.xml file...but I can't seem to figure out how to edit that to change the search path for the groovyc step.
I had the same problem that NB doesn't run a Groovy script out of the IDE like Eclipse does. I logged an issue and spent more than a year on the netbeans-dev mailing list advocating for it. Often replied to with "we'll be happy to review your pull request" type of stuff. Eventually, when I rage quit the mailing list with a scathing message, Geertjan replied to the issue with a solution.
So, in short, use the old plugin to create a Groovy project and change line 26 in groovy-build.xml to
<groovyc srcdir="#{srcdir}" sourcepath="#{sourcepath}" destdir="#{destdir}" encoding="${source.encoding}" excludes="#{excludes}" includeAntRuntime="true" fork="false">
You can then run your script with Shift+F6.
The project needs the Groovy jars added. It works for me on NB 11, 12 & 13 with Groovy 2.x and Java 8, 11 & 14 so far. I haven't tried it with Groovy 3.x as the groovy-all.jar is deprecated so you'll have to maven or manually manage the Groovy jars.
Also, I collaborated a bit with someone on a new plugin. It works as is but new development has stalled.

Is it possible to run unit tests with wxWidgets with just the console and no UI?

I am trying to run some unit tests for code that makes use of wxWidgets windows. In the process, windows are created, but never displayed. This works fine under Linux where a display is available, but not on build systems that don't have X or any other UI/display.
The error I get is: "Unable to initialize GTK+, is DISPLAY set properly?"
Is it possible to unit test wxWidgets without a display? I'm hoping there is some way to just have a stub or "null" display that doesn't really exist, but would allow the unit tests to execute.
As mentioned, I don't need to actually display any window, but from the working tests on a system with a UI, I do need to initialize the app, and create a top level window, like so:
wxEntryStart(argc, argv);
wxTheApp->OnInit();
wxFrame frame(nullptr, wxID_ANY, "Test Frame");
wxTheApp->SetTopWindow(&frame);
You can set up an Xvfb server (or perhaps an Xvnc server), and use it as your dummy display.

How To Show Hello World with Glade/GtkD and the D Programming Language

On Ubuntu Linux, I can use the Glade application to create a Hello World dialog. Now how do I get the D programming language to display it?
Install the DMD compiler that compiles the D language on your Mac, Linux, or Windows computer. You can get more info about this here.
Install the Glade interface designer on your Mac, Linux, or Windows computer. You can get Glade on Ubuntu Linux quite easy with sudo apt-get install glade, but more information about installing on the various other platforms is here.
Install GTKd on your Mac, Linux, or Windows computer. This is not easy. You will need to start with the documentation at gtkd.org and then interact in the DLang.org Learn forum for more assistance if necessary.
Open Glade and create a new window that has a label on it saying Hello World.
Note that the tools palette in Glade shows a Window widget and an ApplicationWindow widget. Since we're not drawing any menus, ensure you're using the Window widget instead of the ApplicationWidget. If you fail to do that, you'll get warnings when running the application, talking about some missing menu calls.
Save it as hello.glade.
Open your hello.glade file in a text editor and look for a line that looks similar to this:
<object class="GtkWindow" id="window1">
Write down on a piece of paper that id attribute.
Create a hello.d script in the same directory as this hello.glade file and alter the following contents, changing the window1 to whatever was your id you wrote down earlier.
import gtk.Builder;
import gtk.Main;
import gtk.Widget;
import gtk.Window;
import std.stdio;
int main (string[] args)
{
Main.init(args);
Builder b = new Builder();
b.addFromFile("hello.glade");
Window w = cast(Window)b.getObject("window1");
w.addOnHide( delegate void(Widget aux){ Main.quit(); } );
w.showAll();
Main.run();
return 0;
}
Compiling is tricky. On Ubuntu Linux, I had to create a statement like the following. You may have to interact in the dlang.org Learn forums for your particular platform.
# dmd hello.d `pkg-config --cflags --libs gtkd3`
Once compiled, you can run your D executable to show the Hello World dialog. On Ubuntu Linux, I simply did:
# ./hello
Note that when you see the window and close it, you may receive some warnings on Linux. (On other platforms, this may vary.) I was receiving a warning about "Couldn't connect to accessibility bus - connection refused". The fix at least on Linux is to add this to your ~/.bashrc script at the bottom:
export NO_AT_BRIDGE=1
Now when you open the command prompt and run your compiled D command "hello" again,
it will not show that error.
If you get errors regarding menus, then you used an ApplicationWindow widget instead of a
Window widget, and will need to switch that in Glade.
Adding Buttons & Signals
The way I do it is to click on a widget in Glade, click Signals, find the event I want to add, such as clicked, and then in the Handler column, type in a function. For example, on a button1, I would type onButton1Clicked. Save the file.
Now, in your D source code, right after you create your Window object, add this code:
b.connectSignals(null);
...where b is your Builder variable.
In your D source code, add a function for this signal. For instance, I did:
extern(C) void onButton1Clicked()
{
writeln("got here");
Main.quit();
}
Note that in this case, the extern(C) is required.
Recompile and run your application. You'll see that it automatically runs your new function for that button click.

Flashdevelop + haxe -- repeated "An I/O error has occured" errors

I'm getting small dialog boxes that pop up saying I/O Error occurred. What causes this, and how should I fix this?
Edit: what happens is that after i run my flash game, FlashDevelop will try to connect to the Flash debugger, but apparently fail and give me the above error. I have both the debug standalone player and the ActiveX debug control for Firefox.
To activate interactive debugging with haxe/Flash/FlashDevelop you have to add the fdb switch and network-sandbox. To do that open Project -> Properties -> Compiler Options -> Directives and add the following two lines:
fdb
network-sandbox
That should be all you need. After that you should be able to set breakpoints, inspect object fields and local variables and profile your code.
I didn't have haxe, but I had the same error and to get rid of it I followed the advice from here:
Specify the path to the debug player
(flashplayer_10_sa_debug.exe or
FlashPlayerDebug.exe in the SDK) in
FlashDevelop Tools > Program settings > FlashViewer

Resources