I'm new to Java and playing with Titan DB.
Per the documentation of the Cassandra backend, TitanFactory has a static method build():
TitanGraph g = TitanFactory.build()
.set("storage.backend","cassandra")
.set("storage.hostname","127.0.0.1")
.open();
However, when looking at the source, it only seems to have an overloaded open() method:
package com.thinkaurelius.titan.core;
import com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration;
import com.thinkaurelius.titan.graphdb.database.StandardTitanGraph;
import org.apache.commons.configuration.Configuration;
import java.io.File;
public class TitanFactory {
public static TitanGraph open(String directoryOrConfigFile) {
return open(GraphDatabaseConfiguration.getConfiguration(new File(directoryOrConfigFile)));
}
public static TitanGraph open(Configuration configuration) {
return new StandardTitanGraph(new GraphDatabaseConfiguration(configuration));
}
}
I thought maybe the version that's up on GitHub is newer than the build I have, but I've got the latest version and GitHub says the file was last modified in May. So I'm thinking I've got to be missing something. TitanFactory.build() does, indeed, work. It returns a TitanFactory Builder. So, where does build come from?
MVN Repository shows the library at version 0.5.1. The code you download with the maven dependency contains a TitanFactory#build() method.
I'm not sure which git branch contains the most up to date code (doesn't seem like master), but this one seems promising.
Related
I am making a custom two block long model called "littleguys:operating_table" and I watched tutorials to make it face the direction I want when it is placed. I made a custom OperatingTable class here:
package com.soliid.littleguys.blocks;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.StateContainer;
import net.minecraftforge.common.ToolType;
public class OperatingTable extends HorizontalBlock
{
public OperatingTable()
{
super(AbstractBlock.Properties.of(Material.STONE)
.harvestLevel(1)
.harvestTool(ToolType.PICKAXE)
.sound(SoundType.STONE)
.requiresCorrectToolForDrops()
.strength(3.5f, 4.0f)
);
}
#Override
protected void fillStateContainer (StateContainer.Builder<Block, BlockState> builder)
{
builder.add(FACING);
}
#Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
}
}
The #Override gives me an error reading
Method does not override method from its superclass, getDefaultState() gives me Cannot resolve method 'getDefaultState' in 'OperatingTable', and getPlacementHorizontalFacing() gives me Cannot resolve method 'getPlacementHorizontalFacing' in 'BlockItemUseContext'.
I now realized that these methods are not in OperatingTables's superclasses (HorizontalBlock and Block) but I want to know which methods are now used instead. There are no errors in the registry of RegistryObject<Block> OPERATING_TABLE or RegistryObject<Item> OPERATING_TABLE_ITEM.
This class is not complete but I cannot continue until I resolve the error.
There are several possibilities, but most cases are cache issue.
Please try invalidate cache and restart IntelliJ.
If issue persist, then sync Gradle project manually.
In build.gradle, on line 34, mappings is defined as channel: 'official', version: '1.16.5'. This should be changed to channel: 'snapshot', version: '[snapshot version]'. The version I used was '20210309-1.16.5'. Then, rebuild the gradle in Terminal using gradlew genIntellijRuns.
I am migrating a Java code that is running on Java 8 and I need to compile it to run on Java 17, so Just downloaded eclipse 2021-09 import the code from Git, change project facet selecting Java, add to Java Build Path the libraries.
libraries added
This is the code:
package itksoluciones.avl.lst.dboperation;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
public class PoolConexionUC {
public static DataSource dataSourceUC;
public PoolConexionUC() {
inicializaDataSourceUC();
}
private void inicializaDataSourceUC() {
BasicDataSource basicDataSourceUC = new BasicDataSource();
basicDataSourceUC.setDriverClassName(DataConexion.driverUC);
basicDataSourceUC.setUsername(DataConexion.userUC);
basicDataSourceUC.setPassword(DataConexion.passUC);
basicDataSourceUC.setUrl(DataConexion.urlUC);
basicDataSourceUC.setMaxActive(Integer.parseInt(DataConexion.maxActiveUC));
basicDataSourceUC.setMaxIdle(DataConexion.defaultMaxIdleUC);
basicDataSourceUC.setMaxWait(DataConexion.defaultMaxWaitUC);
basicDataSourceUC.setRemoveAbandoned(DataConexion.removeAbandonedUC);
basicDataSourceUC.setRemoveAbandonedTimeout(DataConexion.removeAbandonedTimeoutUC);
basicDataSourceUC.setValidationQuery(DataConexion.validationQueryUC);
basicDataSourceUC.setTestOnBorrow(DataConexion.testOnBorrowUC);
dataSourceUC = basicDataSourceUC;
}
}
This are the two errors:
Import org.apache could not be resolved
and
BasicDatasourceCore could not be resolved to a type
Errors
As you could see from the error the library seems available, also it autocompletes when typing.
Also one of the solutions suggested by eclipse is to import org.apache.commons.dbcp.BasicDataSource. (after doing it by double clicking on the suggestion first error is resolved but the second one persists).
What is also very curious is that if I copy paste the class PoolConexionCore to PoolConexionCore2. The problem is gone in PoolConexionCore2.
BUT I HAVE MANY CLASSES WITH THE SAME PROBLEM so I really appreciate any suggestion to avoid having to be dedicated to copy pasted for several days.
After doing copy paste
Edited to restart question from scratch due to complaints. I am a newbie to this format and to intellij so please excuse...
I am building a project in intellij for class. This project imports jnetcap and uses it to process a captured pcap file. My issue is I have two class files I am trying to integrate. NetTraffic which is the user interface class, and ProcessPacket that actually reads in the packet and does the work.
I have tried to make a project and import ProcessPacket into NetPacket but have been unsuccessful so far. I am sure I am missing something simple in this process but I just can not find anything showing the proper way to do this.
I have gotten it working by making a package under the src directory and adding both files to that package. This doesn't require an import from the NetPacket class and seems to work but my worry is that I need to be able to run this from a linux command line. I have been working all semester so far with everything in one source file so it hasn't been an issue until now. I don't remember using packages in the past under eclipse to do this.
Can someone offer a step by step process on how to properly add these source files to my project so that I am able to import ProcessPacket into NetTraffic or will leaving like this in a package work fine?
The files in question reside in package named nettraffic in src directory.
NetTraffic.java
package nettraffic;
public class NetTraffic {
public static ProcessPacket pp;
public static void main (String args[]) {
pp = new ProcessPacket();
pp.PrintOut();
}
}
ProcessPacket.java
package nettraffic;
import org.jnetpcap.*;
public class ProcessPacket {
public ProcessPacket() {
}
public void PrintOut() {
System.out.println("Test");
}
}
Note there is no real functionality in these at this time. Just trying to get the class import syntax correct before continuing. Again while this seems to work as a package I want to have it done without using a package and importing ProcessPacket.java into NetTraffic.java.
public class NetTraffic {
ProcessPacket pp = new ProcessPacket();
pp.PrintOut();
}
You're calling the PrintOut() method outside of any constructor or method or similar block (static or non-static initializer blocks...), and this isn't legal. Put it in a constructor or method.
public class NetTraffic {
public NetTraffic() {
ProcessPacket pp = new ProcessPacket();
pp.PrintOut();
}
}
I'm trying to setup an application that runs on OSGi internally and have tried using the tutorial here, but I get the error "The method getBundleContext() is undefined for the type Framework" all the time. As far as I can tell, I'm using the right library, but it's not specified in the mentioned article, so I'm not 100% sure. I've also tried the examples on Apache's website, here, which results in the same issue. Code below:
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
public class Main {
public static void main(String[] args) throws BundleException {
FrameworkFactory frameworkFactory = ServiceLoader.load(FrameworkFactory.class).iterator().next();
Map<String, String> config = new HashMap<String, String>();
Framework framework = frameworkFactory.newFramework(config);
framework.start();
// Throws error that it cannot find method getBundleContext()
BundleContext context = framework.getBundleContext();
List<Bundle> installedBundles = new LinkedList<Bundle>();
installedBundles.add(context.installBundle("file:org.apache.felix.shell-1.4.2.jar"));
installedBundles.add(context.installBundle("file:org.apache.felix.shell.tui-1.4.1.jar"));
for (Bundle bundle : installedBundles) {
bundle.start();
}
}
}
The only thing that makes sense is that either I'm using the wrong libraries, or the libraries have changed and the method I'm attempting to call has since been deprecated out in the last 4 years. Anyone know how I can fix this?
I doubt it makes much of a difference, but in case it does, I'm using Bndtools for Eclipse to create this project.
Found the issue. Apparently, the import of osgi.core that was in the Bndtools' project build path was out of date, preventing the code from accessing the correct version of the framework libraries. Updating that fixed the issue.
Additional side-note; Since I'm using Bndtools, I was adding this to the project build path via the bnd.bnd file's build tab. This, however, was not grabbing the correct version of osgi.core, so I had to go under source and add the version=latest in order to force it to get the latest version available, so the line now appears as: osgi.core;version=latest where it was previously just osgi.core under the -buildpath: section.
Can someone please correct me, I've found this example online and bunch of others not working, this particular example throws the following error :
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/SetUtils
at org.quartz.JobDetail.<init>(JobDetail.java:85)
at tralala.org.xml.CronSchedule.<init>(CronSchedule.java:13)
at tralala.org.xml.CronSchedule.main(CronSchedule.java:20)
Here is the code :
CronJob.java
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class CronJob implements Job {
public void execute(JobExecutionContext arg0) throws JobExecutionException {
System.out.println("PRINT SOME TEXT LINE");
}
}
CronSchedule.java
import org.quartz.CronTrigger;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.JobDetail;
public class CronSchedule {
public CronSchedule ()throws Exception {
SchedulerFactory sf=new StdSchedulerFactory();
Scheduler sched=sf.getScheduler();
JobDetail jd=new JobDetail("job1","group1",CronJob.class);
CronTrigger ct=new CronTrigger("cronTrigger","group2","0 0/1 * * * ?");
sched.scheduleJob(jd,ct);
sched.start();
}
public static void main(String args[]){
try{
new CronSchedule();
}catch(Exception e){}
}
}
I just wanna run(that is actually works) any example of quartz .. I've been searching for some time now and every example either has compile error or like this one(rare one) throws an error. I just wanna run it this one or any .. just to get some inside with a concrete example. I've been reading http://www.opensymphony.com/quartz/wikidocs/TutorialLesson1.html, the examples don't compile .. any suggestions ? tnx
The error just shows that you don't have the class org.apache.commons.collections.SetUtils in your class path. So you should ensure that. You can download the library from here.
Then extract the download file. You should see a file commons-collections-3.2.1.jar. You just place that file in your class path. OR run it with the option '-cp commons-collections-3.2.1.jar'.
Add to the class path the library containing the SetUtils class.
You can find it here.
You should add commons-collections (v3.1) to you classpath. It's also bundled in the Quartz distribution.
It will probably be much easier for you if you start with the examples that come bundled with in the Quartz distribution archive. They are in the examples subdirectory and for each example there's a script to run it (alongside the ant-based compilation script of course). Study these scripts to see how everything fits together. As Quartz comes bundled with all needed dependencies you should be able to run the examples without downloading whatsoever.