How to call a paint class from another .jar file - java

I have made a .jar file in Eclipse to call a paint class. When I finish it gives me an error:
JAR export finished with warnings. See details for additional information.
Exported with compile warnings: Graphics/src/G1.java
Jar export finished with problems. See details for additional information.
Could not find main method from given launch configuration.
Here is my code to call the paint method:
public class G1Starter {
public void main(String[] args)
{
Graphics1 g1 = new Graphics1();
g1.repaint();
}
}
I tried making a main method in the Graphics1 class but it did not work.

Add the static keyword so that the application has a valid entry point
public static void main(String[] args)

Method 'main' should be 'static'
public static void main(String[] args)

Related

Debug Imported Files in VS Code

I have recently set up the Java extension for VS Code.I have a folder that contains two files Main.java and Person.java. Main.java calls Person.java. When I set a breakpoint in Main.java, everything works as normal.However, when I set a breakpoint in Person.java, it just skips over it.
Are there any workarounds in this issue?
Main.java file
public class Main {
public static void main(String[] args) {
System.out.println("Hello World!");
Person person = new Person();
person.speak();
}
}
Person.java file
public class Person {
public void speak(){
System.out.println("Speak!");
//breakpoint on this line right here gets skipped
System.out.println("Speak!");
}
}
Run -> Start Debugging, it stops at the breakpoint:

Not executing while running the java program in geany

I don't think there are any problems in my java code since I ran the program properly in BluJ, but I use geany extensively instead. However, a strange problem occurred today while building the program in geany. I have defined the main method properly in my code, but despite my program got compiled without any errors, while running it after executing the program in geany I got this error:
Error: Main method not found in class Ter, please define the main method as: public static void main(String[] args) or a JavaFX
application class must extend javafx.application.Application
My program is:
public class Ter {
public static void main(String[] args) {
int scored=3;
int concede=5;
char result = (scored > concede) ? 'W':'L';
System.out.println(result);
}
}

Using package while running; Error "Could not find or load main class"

classpath= C:\Program Files\Java\jdk1.8.0_111\jre\lib\;C:\Program Files\Java\jdk1.8.0_111\bin;
path=C:\Program Files\Java\jdk1.8.0_111\bin;C:\Program Files\Java\jre1.8.0_111\bin;
package seleniumTest;
public class SampleTest {
public static void main(String[] args)
{
System.out.println("hello");
}
}
My question is I am not able run the Java file while using the package.
I am new to Java so not able to find the root cause. Please help me out.
Its not able to reach the main class.

Intellij14.1 Error:No main class for module

I have just try HelloWorld
public class hw {
public static void main(String []args){
System.out.println("HelloWorld");
}
}
but, console said when I tried to compile:
Error:No main class for module: HelloWorldTest
Error:Compilation failed
I don't know I don't know what I have wrong, Why it give me this warn ?
Create a file HelloWorld.java at the root of your source package:
public class HelloWorld {
public static void main(String... args) {
System.out.println("HelloWorld");
}
}
Then from the project explorer (left pane), right click on your HelloWorld class, and select Run 'HelloWorld.main()'
Do you have the Haxe plugin installed?
If so it's likely the source of the problem.
https://devnet.jetbrains.com/thread/435604?tstart=0 and https://devnet.jetbrains.com/thread/435708
Try the fix in the first link or uninstall the plugin.

Java: Can't get my main method to work

I'm using Fedora and I have had some issues to get javac to work (I finally succeeded by making an alias). But now I can't execute my java code. I get the error in the title.
Here is the class that contains the main method:
public class test
{
public static void main(String args)
{
int res[]= {4,2,6};
res=Trieur.tri(res);
for(int i: res)
System.out.println(i);
}
}
I've been trying a lot of solutions in this forum but none seems to work. The program compiles successfully.
Can you please help me?
change this:
public static void main(String args[])
Or as public static void main(String[] args). Either syntax is valid in Java, although this format is arguably slightly more popular.

Categories