Jena TDB java.lang.ExceptionInInitializerError

我正在使用Jena TDB加载RDF数据集并对其进行SPARQL查询。 我正在使用以下maven依赖项: org.apache.jena apache-jena-libs pom 3.0.1 这是我试图创建TDB数据集的java代码: public void loadDirectory(String outputFile){ Dataset dataset = TDBFactory.createDataset(directoryPath); Model tdb = dataset.getDefaultModel(); FileManager.get().readModel(tdb, outputFile); tdb.close(); dataset.close(); LOG.info(“RDF dataset loaded to memory”); } 它在函数的第一行失败:TDBFactory.createDataset(directoryPath),带有以下错误消息: Exception in thread “main” java.lang.ExceptionInInitializerError at org.sdw.model.JenaModel.loadDirectory(JenaModel.java:69) at org.sdw.Main.main(Main.java:75) Caused by: java.lang.NullPointerException at org.apache.jena.tdb.sys.EnvTDB.processGlobalSystemProperties(EnvTDB.java:33) at org.apache.jena.tdb.TDB.init(TDB.java:250) at org.apache.jena.tdb.sys.InitTDB.start(InitTDB.java:29) at org.apache.jena.system.JenaSystem.lambda$init$40(JenaSystem.java:114) at java.util.ArrayList.forEach(ArrayList.java:1249) at org.apache.jena.system.JenaSystem.forEach(JenaSystem.java:179) […]

JavaFX在多个页面上打印tableview

所以,我的问题是我需要打印我的tableview的内容,但我有很多项目,它只打印其中的前23个。 我已经在这里找到了一些解决方案,遗憾的是它们并没有多大帮助。 这是我的打印方法: @FXML private void printIt() { Printer printer = Printer.getDefaultPrinter(); PageLayout pageLayout = printer.createPageLayout(Paper.A4, PageOrientation.LANDSCAPE, Printer.MarginType.DEFAULT); double scaleX = pageLayout.getPrintableWidth() / logBookTable.getBoundsInParent().getWidth(); double scaleY = pageLayout.getPrintableHeight() / logBookTable.getBoundsInParent().getHeight(); logBookTable.getTransforms().add(new Scale(scaleX, scaleY)); PrinterJob job = PrinterJob.createPrinterJob(); if (job != null) { boolean successPrintDialog = job.showPrintDialog(dialogStage); if(successPrintDialog){ boolean success = job.printPage(pageLayout,logBookTable); if (success) { job.endJob(); […]

为什么这个表达式i + = i ++与Java和C不同?

我知道前缀和后缀操作…… ++ i和i ++之间的区别等等。 但我想我在这里遗漏了一些东西。 您可以在下面找到代码: package test; public class Test { public static void main (String[] args) { int i=0; i+=i++; System.out.println(i); // Prints 0 i = i + (i++); System.out.println(i); // Prints 0 i = i + (i+1); System.out.println(i); // Prints 1 } } 所以输出是: 0 0 1 我在C中尝试了相同的代码: #include #include main() { […]

Java中的BMP BufferedImage

我有一个BufferedImage对象,我想将其编码为BMP格式并将其保存到磁盘。 我该怎么做呢? 在JPEG它没关系: BufferedImage img; //here is an image ready to be recorded into the hard disk FileOutputStream fout = new FileOutputStream(“image.jpg”); JPEGImageEncoder jencoder = JPEGCodec.createJPEGEncoder(fout); JPEGEncodeParam enParam = jencoder.getDefaultJPEGEncodeParam(img); enParam.setQuality(1.0F, true); jencoder.setJPEGEncodeParam(enParam); jencoder.encode(img); fout.close();

降低静态方法的可见性

我知道一个孩子不能降低非静态方法的可见性,我理解为什么会这样。 然而,我已经阅读过“静态方法可以通过重新声明隐藏”。 但是我不明白如何在Java中实现这一点。 这真的有可能吗? 如果是的话,该怎么做(代码示例)以及它为什么被引入(它似乎与非减少接口可见性的原则相矛盾)?

spring注释不起作用

我从Spring Framework开始,想要使用annotatios做一个HelloWorld,我已经让它创建了一个控制器和一个视图,我猜是基本的你好工作; 但是,我想使用annotatios因为我不能再使用SimpleFormController(不推荐使用)。 我得到的错误是Estado HTTP 404 – /av/index.jsp 我正在使用Netbeans,我基于它提供的基本模板的示例。 我有以下文件,我很确定这是一个错误的配置,但我找不到任何可以帮助我到目前为止。 提前致谢。 web.xml中 contextConfigLocation /WEB-INF/applicationContext.xml org.springframework.web.context.ContextLoaderListener dispatcher org.springframework.web.servlet.DispatcherServlet 1 dispatcher *.do 30 redirect.jsp 调度员servlet.xml中 / .jsp indexController.java package controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.portlet.ModelAndView; @Controller public class IndexController { @RequestMapping(value=”/index.do”, method= RequestMethod.GET) public ModelAndView inicio (){ ModelAndView mv = new ModelAndView(“index”); mv.addObject(“usuario”, “jaxkodex”); […]

URL可以通过浏览器访问,但仍然可以通过URLConnection访问FileNotFoundException

我使用HttpURLConnection连接到网站并接收ResponseCode = 404(HTTP_NOT_FOUND)。 但是我在浏览器(IE)中打开网站没有问题。 为什么差异,我能做些什么呢? 问候,帕万 这是我的计划 import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; public class TestGet { private static URL source; public static void main(String[] args) { doGet(); } public static void doGet() { try { source = new URL(“http://localhost:8080/”); System.out.println(“Url is” + source.toString()); URLConnection connection = source.openConnection(); connection.setRequestProperty(“User-Agent”,”Mozilla/5.0 ( compatible […]

如何修复ClassNotFoundException:org.apache.commons.logging.LogFactory?

当我运行应用程序时它会获得exception Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.hibernate.dialect.Dialect.(Dialect.java:58) Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) … 1 more 我已将所有jar文件放在lib文件夹中。 我不知道如何解决这个问题,我的错误在哪里。

为什么Java中没有全局变量?

为什么Java中没有全局变量?

如何使用selenium / webdriver将文本输入到tinceMCE editior中

我正在尝试使用Selenium / Webdriver自动将一些文本插入到使用tinymce创建的文本框中 文本框不是普通的香草文本框,因此以下不起作用: System.out.println(“Finding text input element”); WebElement element = inputWebDriver.findElement(By.xpath(“//html/body/div/form/div/div/div[2]”)); //not working //WebElement element = inputWebDriver.findElement(By.tagName(“form”)); // not working //WebElement element = inputWebDriver.findElement(By.id(“tinymce”)); // not working System.out.println(“Entering something in text input”); element.sendKeys(“Test text”); 喜欢纯文本框可以正常工作http://sofzh.miximages.com/java/selenium-google-code-issue-archive 注意:通过selenium,我无法在’embedded’html doc中找到任何元素(我得到元素未找到错误) 我发现一个python等同于上面完成,但是,仍然希望在我的java代码中完成它: browser.execute_script(“tinyMCE.activeEditor.setContent(‘{}’)”.format(testTextVar))