Compile Error: Package sqlj.runtime does not exist - java

I am trying to do a homework assignment in a database course that requires me to use sqlj. It is supposed to make a connection to a SQL database running on my computer. When copying and pasting the example code into Netbeans I get a compile error:
package sqlj.runtime does not exist: import sqlj.runtime.*;
import java.sql.*;
import java.io.*;
import sqlj.runtime.*;
import sqlj.runtime.ref.*;
import oracle.sqlj.runtime.*;
public class A10Q1 {
public static void main(String[] args) {
DefaultContext cntxt = oracle.getConnection("url", "user", "pswd", true);
}
}
I changed the inputs on the getConnection function.

Related

What is wrong with my Java import statement?

Hello I am new to Java and new to trying out Unit Testing for the first time on a simple program but my import.main.BalancedQuestionMarks; statement is not getting recognized in my test file. I don't understand why my test file isn't recognizing my main file.
Here is my test file
import main.BalancedQuestionMarks;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class BalancedQuestionMarksTest {
#Test
public void onlyQuestionMarkReturnsTrue() {
assertTrue(BalancedQuestionMarksTest.hasBalancedMarks("??"), true);
}
}```
Here is the error when I try to run:
java: cannot find symbol
symbol: method hasBalancedMarks(java.lang.String)
location: class test.BalancedQuestionMarksTest

The import org.opencv.imgcodecs.Imgcodecs cannot be resolved

I installed OpenCV (opencv-3.0.0-alpha) and it works properly but I can't use that import:
import org.opencv.core.*;
import org.opencv.imgcodecs.Imgcodecs;
public class Main {
public static void main(String[] args) {
// System.loadLibrary("opencv_java244");
// Mat m = Highgui.imread("C:/Users/raj/Desktop/sa1.png",
// Highgui.CV_LOAD_IMAGE_COLOR);
// new LoadImage("C:/Users/raj/Desktop/dst1.jpg", m);
}
}
I get this error
The import org.opencv.imgcodecs.Imgcodecs cannot be resolved
How can I solve this?
OpenCV 3.0.0 is using the import:
import org.opencv.imgcodecs.Imgcodecs;
However the library you are using (OpenCV 2.4.1) is using different import for the same functionalites:
import org.opencv.highgui.Highgui;
https://fossies.org/diffs/opencv/2.4.11_vs_3.0.0-rc1/modules/java/android_test/src/org/opencv/test/highgui/HighguiTest.java-diff.html
Basically you are trying to import something that doesn't exist in the version you are using.
Now you can either use Highgui or get the jar for OpenCV 3.1.x

Java Network Simulator Getting Started

I am working on simulating a network topology with Java Network Simulator(JNS). I have followed the tutorial which is in documentation of JNS download. Following is the code of the example:
package simulator_;
import java.awt.peer.TextComponentPeer;
import java.io.IOException;
import jns.Simulator;
import jns.element.DuplexInterface;
import jns.element.DuplexLink;
import jns.element.Interface;
import jns.element.Link;
import jns.element.Node;
import jns.trace.Event;
import jns.trace.Trace;
import jns.util.IPAddr;
public class simu {
public static void main(String[] args) {
Simulator sim=Simulator.getInstance();
Node src=new Node("Source node");
Node router=new Node("Router");
Node dest=new Node("Destination node");
sim.attach(src);
sim.attach(router);
sim.attach(dest);
Interface src_iface=new DuplexInterface(new IPAddr(192,168,1,10));
src.attach(src_iface);
sim.attach(src_iface);
Interface dest_iface=new DuplexInterface(new IPAddr(128,116,11,20));
dest.attach(dest_iface);
sim.attach(dest_iface);
Interface route_iface192=new DuplexInterface(new IPAddr(192,168,1,1));
Interface route_iface128=new DuplexInterface(new IPAddr(128,116,11,1));
router.attach(route_iface192);
router.attach(route_iface128);
sim.attach(route_iface192);
sim.attach(route_iface128);
Link link_src_router=new DuplexLink(1000000,0.001);
Link link_router_dest=new DuplexLink(64000,0.1);
src_iface.attach(link_src_router,true);
route_iface192.attach(link_src_router,true);
sim.attach(link_src_router);
route_iface128.attach(link_router_dest,true);
dest_iface.attach(link_router_dest,true);
sim.attach(link_router_dest);
src.addDefaultRoute(src_iface);
dest.addDefaultRoute(dest_iface);
router.addRoute(new IPAddr(192,168,1,0),new IPAddr(255,255,255,0),
route_iface192);
router.addRoute(new IPAddr(128,116,11,0),new IPAddr(255,255,255,0),
route_iface128);
sim.run();
}
}
The problem I am facing is when I call sim.run(), the program throws me NullPointerException error. I am a newbie in JNS. Kindly guide if how can I successfully create a file foe javis to Simulate with the help of above code. I am using Eclipse IDE.
Thanks in advance.
try setting a trace instance
sim.setTrace(new JavisTrace("output.txt"));

passing argument to WordCram code

I have the following question: I am trying to execute the usConstitution wordcram example (code follows) and if provided as is the code executes in eclipse, the applet starts and the word cloud is created. (code follows)
import processing.core.*;
//import processing.xml.*;
import wordcram.*;
import wordcram.text.*;
import java.applet.*;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;
import java.awt.event.FocusEvent;
import java.awt.Image;
import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;
import java.util.zip.*;
import java.util.regex.*;
public class usConstitution extends PApplet {
/*
US Constitution text from http://www.usconstitution.net/const.txt
Liberation Serif font from RedHat: https://www.redhat.com/promo/fonts/
*/
WordCram wordCram;
public void setup() {
size(800, 600);
background(255);
colorMode(HSB);
initWordCram();
}
public void initWordCram() {
wordCram = new WordCram(this)
.fromTextFile("http://www.usconstitution.net/const.txt")
.withFont(createFont("https://www.redhat.com/promo/fonts/", 1))
.sizedByWeight(10, 90)
.withColors(color(0, 250, 200), color(30), color(170, 230, 200));
}
public void draw() {
if (wordCram.hasMore()) {
wordCram.drawNext();
}
}
public void mouseClicked() {
background(255);
initWordCram();
}
static public void main(String args[]) {
PApplet.main(new String[] { "--bgcolor=#ECE9D8", "usConstitution" });
}
}
My problem is the following:
I want to pass through main (which is the only static class) an argument so as to call the usConstitution.class from another class providing whichever valid filename I want in order to produce its word cloud. So how do I do that? I tried calling usConstitution.main providing some args but when I try to simply print the string I just passed to main (just to check if it is passed) I get nothing on the screen. So the question is How can I pass an argument to this code to customize .fromTextFile inside initWordCram ?
Thank you a lot!
from: https://wordcram.wordpress.com/2010/09/09/get-acquainted-with-wordcram/ :
Daniel Bernier says:
June 11, 2013 at 1:13 am
You can’t pass command-line args directly to WordCram, because it has no executable.
But you can make an executable wrapper (base it on the IDE examples that come with WordCram), and it can read command-line args & pass them to WordCram as needed.
FYI, it’ll still pop up an Applet somewhere – AFAIK, you can’t really run Processing “headless.” But that’s usually only a concern if you’re trying to run on a server.

Error when using ProtocolLibrary PacketAdapter()

I am making a Craftbukkit plugin that has a message in the player count list, Like HIVE-MC or Omega Realm. I am coding in Ecplise and using ProtocolLib v3.2.0 and Craftbukkit 1.7.2 R0.3. I am new to java and don't understand it much. I do know that everything is imported.
So far, here are the imported methods, code, and the error
Methods:
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.ListenerOptions;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
Code:
private List<WrappedGameProfile> message = new ArrayList<WrappedGameProfile>();
public void onEnable() {
if(!new File(getDataFolder(),"RESET.FILE").exists()){
try {
getConfig().set("PCMessage",
Arrays.asList(new String[]{"First Line", "Second Line"}));
new File(getDataFolder(),"RESET.FILE").createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
saveConfig();
for (String str : getConfig().getStringList("PCMessage"))
message.add(new WrappedGameProfile("1", str));
ProtocolLibrary
.getProtocolManager()
.addPacketListener(
new PacketAdapter(
this,ListenerPriority.NORMAL,
Arrays.asList(new PacketType[] {PacketType.Status.Server.OUT_SERVER_INFO}),
new ListenerOptions[] { ListenerOptions.ASYNC })); {
}
}
Error:
Cannot instantiate the type PacketAdapter
As you will see in the Javadocs for PacketAdapeter, it is declared as:
public abstract class PacketAdapter implements PacketListener
abstract means the class is not a full class, and must be implemented as a full class or anonymous class, it cannot be instantiated. You need to find a subclass of PacketAdapter, or make one yourself.
For more information, see the Java Tutorial for Abstract Methods and Classes.

Categories