I am trying to run the below code in Eclipse.
It's giving me an error "Editor does not contain a main type" but it does as you can see public static void main(String args[]).
Anyone know how to run this or why it does not recognize the main method?
package org.axiondb.functional;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* #version $Revision: 1.26 $ $Date: 2005/05/03 18:02:23 $
* #author Rodney Waldhoff
* #author Chuck Burdick
*/
public class TestAll extends TestCase {
public TestAll(String testName) {
super(testName);
}
public static void main(String args[]) {
String[] testCaseName = { TestAll.class.getName() };
junit.textui.TestRunner.main(testCaseName);
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(TestDatatypes.suite());
suite.addTest(TestDDL.suite());
suite.addTest(TestDQL.suite());
suite.addTest(TestDQLMisc.suite());
suite.addTest(TestDQLDisk.suite());
suite.addTest(TestDQLWithArrayIndex.suite());
suite.addTest(TestDQLDiskWithArrayIndex.suite());
suite.addTest(TestDQLWithBTreeIndex.suite());
suite.addTest(TestDQLDiskWithBTreeIndex.suite());
suite.addTest(TestDML.suite());
suite.addTest(TestDMLMisc.suite());
suite.addTest(TestDMLDisk.suite());
suite.addTest(TestDMLWithArrayIndex.suite());
suite.addTest(TestDMLDiskWithArrayIndex.suite());
suite.addTest(TestDMLWithBTreeIndex.suite());
suite.addTest(TestDMLDiskWithBTreeIndex.suite());
suite.addTest(TestMemoryClob.suite());
suite.addTest(TestDiskClob.suite());
suite.addTest(TestMemoryBlob.suite());
suite.addTest(TestDiskBlob.suite());
suite.addTest(TestThreadedSelect.suite());
suite.addTest(TestIndexedJoin.suite());
suite.addTest(TestBugs.suite());
suite.addTest(TestAxionBTreeDelete.suite());
suite.addTest(TestSpecials.suite());
suite.addTest(TestFunctions.suite());
suite.addTest(TestThreadedDML.suite());
suite.addTest(TestTransactions.suite());
suite.addTest(TestTransactionsDisk.suite());
suite.addTest(TestConstraints.suite());
suite.addTest(TestBooleanLiterals.suite());
suite.addTest(TestTransactionalLobs.suite());
suite.addTest(TestTransactionalLobsDisk.suite());
suite.addTest(TestMetaData.suite());
suite.addTest(TestMetaDataDisk.suite());
suite.addTest(TestDatabaseLock.suite());
suite.addTest(TestIndexSpecials.suite());
suite.addTest(TestForElmar.suite());
suite.addTest(TestPrepareStatement.suite());
suite.addTest(TestGroupByAndOrderBy.suite());
suite.addTest(TestBinaryStream.suite());
return suite;
}
}
Try reopening the file, then run the test.
Otherwise, restart Eclipse. please let me know if this solves the problem! or else give me more details and I'll try and help.
Related
I want to make a webcam capture software and a stream software using sarxos's webcam library. Wanting to understand the examples first i don't know what to change or add in order to go past this error at import us.sosia.
package us.sosia.video.stream.agent.ui does not exist
package us.sosia.video.stream.handler
Maybe i have to make a Marvin project and change the pow.xml file but i don't know how to do this and still add my sarxos library to the Marvin project using NetBeans.
first class is StreamServer:
package us.sosia.video.stream.agent;
import java.awt.Dimension;
import java.net.InetSocketAddress;
import com.github.sarxos.webcam.Webcam;
public class StreamServer {
/**
* #author kerr
* #param args
*/
public static void main(String[] args) {
Webcam.setAutoOpenMode(true);
Webcam webcam = Webcam.getDefault();
Dimension dimension = new Dimension(320, 240);
webcam.setViewSize(dimension);
StreamServerAgent serverAgent = new StreamServerAgent(webcam, dimension);
serverAgent.start(new InetSocketAddress("localhost", 20000));
}
}
Second class is StreamClient:
package us.sosia.video.stream.agent;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.net.InetSocketAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import us.sosia.video.stream.agent.ui.SingleVideoDisplayWindow;
import us.sosia.video.stream.handler.StreamFrameListener;
public class StreamClient {
/**
* #author kerr
* */
private final static Dimension dimension = new Dimension(320,240);
private final static SingleVideoDisplayWindow displayWindow = new SingleVideoDisplayWindow("Stream example",dimension);
protected final static Logger logger = LoggerFactory.getLogger(StreamClient.class);
public static void main(String[] args) {
//setup the videoWindow
displayWindow.setVisible(true);
//setup the connection
logger.info("setup dimension :{}",dimension);
StreamClientAgent clientAgent = new StreamClientAgent(new StreamFrameListenerIMPL(),dimension);
clientAgent.connect(new InetSocketAddress("localhost", 20000));
}
protected static class StreamFrameListenerIMPL implements StreamFrameListener{
private volatile long count = 0;
#Override
public void onFrameReceived(BufferedImage image) {
logger.info("frame received :{}",count++);
displayWindow.updateImage(image);
}
}
}
I need a way to go past this error.
Thanks in advance.
your first 2 lines in both files are:
package us.sosia.video.stream.agent;
This means that these files should be in the following path
"/us/sosia/video/stream/agent/"
Remove this line from both files.
I'm learning Java and experimenting with Javafx in netbeans.
I am running the sqlite tutorial here: http://www.tutorialspoint.com/sqlite/sqlite_java.htm
When set up as a lone-file it works fine of course.
I'm setting it up in a test project "testDB" and for some reason when I initiate the class the class itself is recognized, but main() is not running.
Here is the testdb file itself:
testDB.java:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package sqlitetest;
import java.sql.*;
/**
*
*/
public class testDB {
public static void main(String args[]) {
//THESE STEPS ARE ON NOT RUNNING (compiles without errors)
System.out.println("testing");
Connection c = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:test.db");
} catch (Exception e) {
System.err.println(e.getClass().getName() + ": " + e.getMessage());
System.exit(0);
}
System.out.println("Opened database successfully");
}
public void makeStuff(){
}
}
sqlitetest.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package sqlitetest;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
/**
*
*/
public class Sqlitetest extends Application {
#Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
testDB test = new testDB();
test.makeStuff();
launch(args);
}
}
I think you are getting confused between a constructor and a main method.
A main method is only invoked when you start the JVM, running that specific class (or if you invoke it explicitly elsewhere).
A constructor is invoked when you create an instance of the class, like you are doing here.
In testdb, change:
public static void main(String args[]) {
to
public testdb() {
Alternatively, invoke testdb.main(args) (or with some other parameter) in Sqlitetest.main.
I am getting error in testng report:
I followed the below steps
I wrote all my testcases in java methods and used java verifications like if else to pass my testcases
2.I created one testng class, in the testng class i called my all java methods
I executed the testng class this class contain around 30 java methods, each and every method is one testcase.
If i execute that class reports generated for testng based annotations, it does not consider the java methods into testcases, how can i call my all java methods? i need to generate reports for my java methods
Here is my code :
import java.io.FileNotFoundException;
import java.io.IOException;
import jxl.read.biff.BiffException;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class DocumentSearchTest {
WebElements webEleObj;
/*
* AllLetter Lettobj ; AllSearch allseObj; AllTranscript TraObj;
*/
FrameSearchExported fseObj;
TextBoxSearch textObj;
DateSinceSearch dateSinceObj;
/*
* public void loginTest() throws FileNotFoundException, BiffException,
* IOException, InterruptedException {
* webEleObj.textbox(webEleObj.properties
* ("Username"),webEleObj.excelRead(1,2,1));
* webEleObj.textbox(webEleObj.properties
* ("Password"),webEleObj.excelRead(2,2,1)); webEleObj.sleep(5000);
* webEleObj.button(webEleObj.properties("Login")); webEleObj.sleep(20000);
*
* }
*/
#BeforeClass
public void start() throws FileNotFoundException, BiffException,
IOException, InterruptedException, RowsExceededException,
WriteException {
// Assert.assertEquals(true, true, "Loggend into application");
webEleObj = new WebElements();
/*
* allseObj = new AllSearch(webEleObj); Lettobj = new
* AllLetter(webEleObj); TraObj =new AllTranscript(webEleObj);
*/
fseObj = new FrameSearchExported(webEleObj);
textObj = new TextBoxSearch(webEleObj);
dateSinceObj = new DateSinceSearch(webEleObj);
webEleObj.browserLaunch();
webEleObj.loginTest();
webEleObj.sleep(20000);
webEleObj.setUpApp();
// webEleObj.excelwrite(4);
System.out.println("hi logged in");
}
#Test
public void ts_1() throws FileNotFoundException, IOException,
InterruptedException, RowsExceededException, BiffException,
WriteException {
webEleObj.sleep(10000);
System.out.println("First TestCase---->");
fseObj.allexportedSearch();
fseObj.letterexportedSearch();
fseObj.transcriptexportedSearch();
fseObj.allnotexpSearch();
fseObj.letternotexpSearch();
fseObj.transcriptnotexpSearch();
fseObj.allsignsearch();
fseObj.lettersignSearch();
fseObj.transcriptsignSearch();
fseObj.allnotsignSearch();
fseObj.letternotsignSearch();
fseObj.transcriptnotsignSearch();
System.out.println("Document Search Test Case Completed");
}
/*
* #Test(enabled=false) public void ts_2() throws FileNotFoundException,
* BiffException, IOException, InterruptedException, RowsExceededException,
* WriteException { System.out.println("Second TestCase---->");
* textObj.accountNo_All(); textObj.accountNo_Letter();
* textObj.accountNo_Transcript(); textObj.firstName_All();
* textObj.firstName_Letter(); textObj.firstName_Transcript();
* textObj.lastName_All(); textObj.lastName_Letter();
* textObj.lastName_Transcript();
*
* }
*/
#Test
public void ts_3() throws FileNotFoundException, IOException,
InterruptedException, RowsExceededException, BiffException,
WriteException {
// webEleObj.sleep(10000);
System.out.println("Third TestCase---->");
dateSinceObj.datesinceAll_Today();
dateSinceObj.datesinceAll_Yesterday();
dateSinceObj.datesinceAll_ThisMonth();
dateSinceObj.datesinceAll_LastMonth();
dateSinceObj.datesinceAll_ThisYear();
dateSinceObj.datesinceAll_LastYear();
dateSinceObj.datesinceLetter_Today();
dateSinceObj.datesinceLetter_Yesterday();
dateSinceObj.datesinceLetter_ThisMonth();
dateSinceObj.datesinceLetter_LastMonth();
dateSinceObj.datesinceLetter_ThisYear();
dateSinceObj.datesinceLetter_LastYear();
dateSinceObj.datesinceTranscript_Today();
dateSinceObj.datesinceTranscript_Yesterday();
dateSinceObj.datesinceTranscript_ThisMonth();
dateSinceObj.datesinceTranscript_LastMonth();
dateSinceObj.datesinceTranscript_ThisYear();
dateSinceObj.datesinceTranscript_LastYear();
// logOut();
}
}
You could use a jUnit testSuite where you can define all the test classes you want to run at the same time:
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
#RunWith(Suite.class)
#SuiteClasses({ MyClassTest.class, MySecondClassTest.class })
public class AllTests {
}
You can find more info # Vogella http://www.vogella.com/articles/JUnit/article.html#juniteclipse_testsuite
Here is your code for calling any java methods in testing class:--
Class A
public class A {
static void method1()
{
System.out.println("Selenium_1");
}
static void method2()
{
System.out.println("Selenium_1");
}
}
Class B
public class B extends A {
public static void main(String ar[])
{
method1();
method2();
}
}
Anyone with experience using Java-Sandbox, I have implemented one of the basic examples found in the documentation but i cant get it working.
Code:
SandPlayground.java
import java.util.concurrent.TimeUnit;
import net.datenwerke.sandbox.*;
import net.datenwerke.sandbox.SandboxContext.AccessType;
import net.datenwerke.sandbox.SandboxContext.RuntimeMode;
import net.datenwerke.sandbox.SandboxedEnvironment;
public class SandPlayground {
/**
* #param args
*/
public static void main(String[] args) {
System.out.println("Running...");
SandboxService sandboxService = SandboxServiceImpl.initLocalSandboxService();
// configure context
SandboxContext context = new SandboxContext();
//context.setRunRemote(true);
context.setRunInThread(true);
context.setMaximumRunTime(2, TimeUnit.SECONDS, RuntimeMode.ABSOLUTE_TIME);
context.addClassPermission(AccessType.PERMIT, "java.lang.System");
context.addClassPermission(AccessType.PERMIT, "java.io.PrintStream");
//run code in sandbox
SandboxedCallResult<String> result = sandboxService.runSandboxed(MyEnvironment.class, context, "This is some value");
// output result
System.out.println(result.get());
}
}
MyEnvironment.java
import net.datenwerke.sandbox.SandboxedEnvironment;
public class MyEnvironment implements SandboxedEnvironment<String> {
private final String myValue;
public MyEnvironment(String myValue){
this.myValue = myValue;
}
#Override
public String execute() throws Exception {
/* run untrusted code */
System.out.println(myValue);
/* return some value */
return "This is a different value";
}
}
And I'm getting the error:
EDIT: I've included the dependencies, but I'm still getting some errors:
With the code above I get:
Exception in thread "main" net.datenwerke.sandbox.exception.SandboxedTaskKilledException: killed task as maxmimum runtime was exceeded
at net.datenwerke.sandbox.SandboxMonitorDaemon.testRuntime(SandboxMonitorDaemon.java:82)
at net.datenwerke.sandbox.SandboxMonitorDaemon.run(SandboxMonitorDaemon.java:57)
at java.lang.Thread.run(Thread.java:724)
and when i remove the context.setMaximumRunTime() call, I get:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/map/IdentityMap ...
Any help is much appreciated.
most likely you are missing the javassist library (see the documentatio of the sandbox for dependencies: http://blog.datenwerke.net/p/the-java-sandbox.html). You'll find the javassist library on sourceforge at: https://sourceforge.net/projects/jboss/files/Javassist/
The javaassist library is used to remove finalizers in loaded code. This can be turned off in the sandbox context:
contex.setRemoveFinalizers(false)
Hope this helps.
Just playing around with java trying to learn it etc.
Here is my code so far, using HtmlUnit.
package hsspider;
import com.gargoylesoftware.htmlunit.WebClient;
/**
* #author
*/
public class Main {
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("starting ");
Spider spider = new Spider();
spider.Test();
}
}
package hsspider;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
/**
* #author
*/
public class Spider {
public void Test() throws Exception
{
final WebClient webClient = new WebClient();
final HtmlPage page = webClient.getPage("http://www.google.com");
System.out.println(page.getTitleText());
}
}
I am using Netbeans.
I can't seem to figure out what the problem is, why doesn't it compile?
The error:
C:\Users\mrblah\.netbeans\6.8\var\cache\executor-snippets\run.xml:45:
Cancelled by user.
BUILD FAILED (total time: 0 seconds)
The row in the xml is:
<translate-classpath classpath="${classpath}" targetProperty="classpath-translated" />
Test is declared to throw Exception. If you add "throws Exception" to your main method it should compile. For example:
/**
* #param args the command line arguments
*/
public static void main(String[] args) throws Exception {
System.out.println("starting ");
Spider spider = new Spider();
spider.Test();
}
What Steve said is correct. But maybe there are some problems with the uppercase character of Test. A method always starts with a lower case character. So test would be better.
Unchecking the "Compile on Save" option of the "Properties" tab in Netbeans 7.1.2 resolved a similar error message for me.