First got this error with Eclipse Neon. Installed Oxygen and get the same error. Under Oxygen, I created a new Java project with a one line Main function to write "Hello, World!":
/**
*/
package com.brindlewaye.hello;
/*
* author Dave
*/
public class Hello {
/*
*/
public Hello() {
// TODO Auto-generated constructor stub
}
/*
* #param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello, World!");
}
}
Same error.
I have searched and found nothing that applied, IMHO, to a simple one line, Hello World, Java project.
What might the problem be?
It seems that my Eclipse workspace had gone wonky. Created a new workspace and migrated all of my Java projects to it. Now all of them build and run fine.
Related
I'm learning JEP and PyDev plugin eclipse and new to Python.
I cannot see my python print and java println statements on Eclipse console tab.
As I'm just trying things out I create a simple python script by creating a new PyDev module and it just has one line (greetings.py):
print("Hello from python");
When I run this I see it in the console when I run it both the PyDev and Jave EE perspective.
Next as the intent of this exercise is to look into JEP to see if it's adequate for my project so I created another Java project with this code:
package my.sand.box;
import jep.Interpreter;
import jep.Jep;
import jep.JepException;
import jep.SharedInterpreter;
public class JepTest {
public static void main(String[] args) throws JepException {
// TODO Auto-generated method stub
System.out.println("hey");
try (Interpreter interp = new SharedInterpreter()) {
//interp.exec("import example_package");
// any of the following work, these are just pseudo-examples
interp.runScript("full/path/to/greetings.py");
interp.eval("import sys");
interp.eval("s = 'Hello World'");
interp.eval("print s");
String java_string = interp.getValue("s").toString();
System.out.println("Java String:" + java_string);
}
}
}
I don't see anyting on the console. Not even the java println statements.
I also recreated both projects in a new workspace and could see the output. What's different between both workspaces is that in the one that's not workign I have other java projects and pydev projects open.
Would appreciate any advice.
I've faced a similar issue working with Jep before, the trick is you need to redirect Python's output stream in your IDE by calling the correct method.
Take a look at https://github.com/ninia/jep/issues/298
As Klodovsky mentioned, you need to redirect Python's output to the stream used by the IDE. I've adapted your example to do this. The key line is the call to SharedInterpreter.setConfig:
package my.sand.box;
import jep.Interpreter;
import jep.JepConfig;
import jep.JepException;
import jep.SharedInterpreter;
public class JepTest {
public static void main(String[] args) throws JepException {
System.out.println("hey");
// Eclipse doesn't use stdout & stderr, so use the streams from Java.
SharedInterpreter.setConfig(new JepConfig()
.redirectStdErr(System.err)
.redirectStdout(System.out));
try (Interpreter interp = new SharedInterpreter()) {
// interp.exec("import example_package");
// any of the following work, these are just pseudo-examples
// Uncomment if you've created a greetings.py script.
// interp.runScript("full/path/to/greetings.py");
interp.eval("import sys");
interp.eval("s = 'Hello World'");
interp.eval("print(s)");
String java_string = interp.getValue("s").toString();
System.out.println("Java String:" + java_string);
}
}
}
Am using Eclipse Neon 3 and was making my usual edits to the formatter when I noticed that everytime I create a new class, it creates two new (or blank) lines between the package declaration and the actual class itself!
package com.myapp;
public class MyClass {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
How to setup the Eclipse formatter to only include one blank line (initially), especially if there's no import declarations used yet, like this:
package com.myapp;
public class MyClass {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
Been trying to fix this myself and would appreciate if someone could point me in the right direction.
Review the code template that was set up in Eclipse by opening up Window > Preferences > Java > Code Style > Code Templates and configure the generated code for New Java Files under the Code header.
The default template given provided was
${filecomment}
${package_declaration}
${typecomment}
${type_declaration}
and the generated code as follows
package com.personal.test.com.personal.test;
public class AppTest {
}
If the template was modified to this, note the extra blank lines.
${filecomment}
${package_declaration}
${typecomment}
${type_declaration}
The following is generated
package com.personal.test.com.personal.test;
public class AppTestWithSpaces {
}
I am trying to run this applet code below.But When I run it .I just get an empty Applet screen that says applet started.
public class Ass extends JApplet{
double sum;
public void init(){
double D1=Double.parseDouble(JOptionPane.showInputDialog("firstvAL"));
double D2=Double.parseDouble(JOptionPane.showInputDialog("secondvAL"));
sum=D1+D2;
}
#Override
public void print(Graphics g) {
// TODO Auto-generated method stub
super.print(g);
g.drawString("Sum is"+sum,44,44);
}
}
And I want to ask one more thing.I have removed eclips ide and downloaded Enterprice edition .And noticed these two section .Why is that? did I make a mistake while removing eclipse folder
I think you should be using paint ( ) instead of print ( ) .
Here while I run java project in netbeans all things are working okay. But after they are built there is not any item added in combobox as it works during netbeans run. The sample code is given below.
First Login JFrame
public class Login_Frame extends javax.swing.JFrame {
welcome w = new welcome();
public Login_Frame() {
initComponents();
}
//button action perform event for dispose this window and open new welcome window
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
.
.
w.setVisible(true);
this.dispose();
.
.
}
}
Second JFrame
public final class welcome extends javax.swing.JFrame {
// comboitem is class in which method for adding item in combobox from sqlite
db is declared
comboitem c = new comboitem();
// textclass is class in which method for changing lowercase text entered in
text to uppercase is declared
textclass tc = new textclass();
public welcome() {
// while I try to run the project using netbeans run project option
// logincall() method initialized and work fine.
Problem
After project built when I try to run the jar file from the cmd. it runs without any
error but logincall() method doesn't work or may be not initialized.
initComponents();
logincall();
.
.
}
public void logincall(){
//Remarks
//tc.uppercase() method is working fine after built. But other c.but_stn() like
// doen't.while during running project through netbeans all thing working fine.
c.bus_stn();
c.bus_trl();
c.inq_stn();
c.editframe();
c.userlist();
c.editTrainStation();
c.editFlightStation();
c.flightFlight();
c.pickupstand();
tc.uppercase();
}
I didn't know what is wrong with it. I searched on google but didn't find any proper answer.
There also any error showing up in netbeans. Please fill free to ask any questions if more information is needed. I appreciate all your replies.
This is my Welcome Main class's main method.
public static void main(String args[]) {
...
look and feel auto generated code
....
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new welcome().setVisible(true);
}
});
}
A couple of things that might be an issue here:
1) Are you running your GUI on the EventDispatchThread? this is mandatory for java swing GUI to be able to work properly. The main reason for this is concurrency. Details here.
2) Are you re-rendering your combobox? it is important that you do this because changes to GUI elements may not be immediately shown.
3) What Database are you using? in order to determine if the fault lies in the code or the DB you could write a test using static data, if it loads in the IDE and outside of it chances are that your code is correct but the DB isn't
I try to use Geoserver-Manager. I says:
package test;
import java.net.MalformedURLException;
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
import it.geosolutions.geoserver.rest.GeoServerRESTReader;
public class RestTester
{
/**
* #param args
* #throws MalformedURLException
*/
public static void main(String[] args) throws MalformedURLException
{
System.out.println("fdfdfd");
// TODO Auto-generated method stub
String RESTURL = "http://localhost:8080/geoserver";
String RESTUSER = "admin";
String RESTPW = "geoserver";
GeoServerRESTReader reader = new GeoServerRESTReader(RESTURL, RESTUSER, RESTPW);
GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSER, RESTPW);
System.out.println("fdfdfd");
}
}
And there is something interesting. I start this application and get nothing in console. No any errors or my prints.
What can be wrong? I use Eclipse Galileo.
UPDATE
More info
Geoserver Manager add to application how java classes not *.jar files.
I delete all classes from project but RestTester. But still not get any prints in console.
UPDATE2
I delete RestTester class. And add new class HelloW.
public class HelloW
{
/**
* #param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
System.out.println("HelloW");
}
}
Run it and get error:
java.lang.NoClassDefFoundError: HelloW
Caused by: java.lang.ClassNotFoundException: HelloW
But when i create new project with same class all works fine. In project where i try Geoserver Manager i add some *.jar but its was only apache commons and jdom libraries, half of then i use in my another applications.