I have been trying to fix this problem for more then 3 hours. I have noticed that there are question with similar problem and i have tried everything but its still not working.
I think that the problem has something to do with JSoup JAR file.
Here is link to similar problem How to add Jsoup in my project?
I have tried to set up both Android and normal Java project and same error appears.
EDIT: Here is the code, just in case
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
public class Klasa {
public static void main(String[] args){
try{
String servisURL = "http://www.sczg.unizg.hr/student-servis/";
Document doc = Jsoup.connect(servisURL).get();
Elements jobNode = doc.select("div.jobBox");
System.console().writer().print(jobNode.get(0).text());
}catch(Exception e){
System.out.println(e.getMessage().toString());
}
}
}
EDIT2: I have solved the problem
Just change System.console().writer().print(jobNode.get(0).text());
to
System.out.print(jobNode.get(0).text());
If you are using Eclipse, then follow these steps,
Right click on your project.
Go to Properties -> Java Build Path
Click on the Source tab -> Add Folder button.
Add the source folder of your project.
In case you want to attach an external source like a jar, click on Link Source.
Related
ok i am a new one here and tried to write an awesome program:
package f;
import javax.swing.*;
public class dasMain {
public static void main(String[] args) {
ImageIcon img = new ImageIcon("pics/daFaq.png");
JOptionPane.showMessageDialog(null, img, "u r heck", JOptionPane.PLAIN_MESSAGE);
}
}
the thing is that if I run the program from Intellij Idea, then everything works fine, but after compilation the picture disappears
here are the source files of the project:
https://i.ibb.co/Njc8jYp/screen.png
i want to run this awesome code with pictures on other computers, but i only know this way and it doesn't work :(
You probably do not know where your program expects the picture to be. If you modify your code slightly, this information would be evident. Make use of
ImageIcon(URL)
File.toURI()
URI.toURL()
With that your code can look like this:
package f;
import javax.swing.*;
import java.io.File;
public class dasMain {
public static void main(String[] args) {
File png = new File("pics/daFaq.png");
System.out.println("Loading image from " + png.getAbsolutePath());
ImageIcon img = new ImageIcon(png.toURI().toURL());
JOptionPane.showMessageDialog(null, img, "u r heck", JOptionPane.PLAIN_MESSAGE);
}
}
Also I am pretty sure you intend to ship the png together with your code, so you better load it as a resource from the classpath. Here is an example.
I also investigated a bit why you would not see any error message or exception. This is documented in ImageIcon. So you might want to verify the image was loaded using getImageLoadStatus().
If you access the resource with the path like pics/file_name.png, then the pics - is the package name. And it must be located in the directory, marked as resource type. For example, create the directory, named resources in your project root, mark this directory as resource type, and move the pics there:
P. S. I would advise to use Maven or Gradle build system for managing project builds. As it is commonly accepted build management systems for the JVM projects. IDE New Project Wizard has the option to create Maven or Gradle based projects.
I'm trying to teach myself java syntax and using minecraft as a platform for diving in. I'm having a problem though because none of my textures are being loaded. For that matter neither are my localizations. Here is the code for my block
package net.richbaird.testtutorial.blocks;
import cpw.mods.fml.common.registry.GameRegistry;
//import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.richbaird.testtutorial.lib.constants;
public class OrangeBlock extends Block {
private String blockName = "orangeBlock";
public OrangeBlock() {
super(Material.rock);
this.setBlockName(constants.MODID + "_" + blockName);
this.setCreativeTab(CreativeTabs.tabBlock);
GameRegistry.registerBlock(this,blockName);
this.setBlockTextureName(constants.MODID + ":" + blockName);
//LanguageRegistry.addName(this,"tutorial block");
}
}
here is my constants class
package net.richbaird.testtutorial.lib;
public class constants {
public static final String MODID = "testtutorial";
public static final String MODNAME = "Test Tutorial";
public static final String VERSION = "1.0";
}
I have my texture saved at
~/IdeaProjects/testmod/src/main/resources/assets/testtutorial/textures/blocks/orangeBlock.png
According to the log it is unable to find my texture. Here's the message I'm getting
[08:08:14] [Client thread/ERROR]:
Using missing texture, unable to load
testtutorial:textures/blocks/orangeBlock.png
java.io.FileNotFoundException: testtutorial:textures/blocks/orangeBlock.png
The client loads and my item shows up but with a default black and purple texture. What have I done wrong? I'm thinking it might have to do with my naming conventions, since the .lang file never gets read either, and the only way I can give my block a friendly name is with the now depreciated LanguageRegistry.addName() method
For those who are curious, it's a bug with intellij 14 looks like. Adding this line to the bottom of the build.gradle that comes with forge
sourceSets {
main { output.resourcesDir = output.classesDir }
}
And running gradle setupDecompWorkspace idea --refresh-dependencies
fixed the problem.
I recently ran into this bug after updating IntelliJ, and while richbai90's solution did fix the immediate issue, it also broke compiling the mod into a jar (the assets folder gets included twice). After some digging around, I eventually found the root of the issue: IntelliJ was delegating the build task to Gradle, which put the assets and classes in separate folders, and Forge didn't know they belong to the same mod. The solution that worked for me was to build and run using the IDE, which is in the Settings dialog under Build, Execution, Deployment | Build Tools | Gradle (the help page has more detailed instructions). On older versions of IntelliJ, this was called "Delegate IDE build/run actions to gradle" (see the help page).
i have been searching around for a few days for the answer to this and i just can't seem to get it to work. I have seen exact examples where it is working for them and I try exactly what they do and it is just not working for me.
Basically what i am trying to do is open a local access DB. I have tried numerous methods and this Jackcess seems by far the best library to use, so i am trying to get it to work with that. I have read their cookbook and gone through all of that, and still no luck so i am coming to you guys in the hope of finding a good solution (i have not posted this question anywhere yet). Here is my code (the relevant part)
The only syntax error i am getting is "DatabaseBuilder.Open" and the error is it cannot find the method, even though i have the libraries included for IO
import com.healthmarketscience.jackcess.*;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Database db = DatabaseBuilder.open(new File("my.mdb"));
try {
Table table = db.getTable("Teams");
} catch (IOException ex) {
Logger.getLogger(Teams.class.getName()).log(Level.SEVERE, null, ex);
}
}
Any help would be greatly appreciated!
The program fails to debug once I have click this buttone the only actual message i can fine is
"Cannot find symbol
Symbol : Method Open(file)
Location : variable.DatabaseBuilder of type Object"
To use Jackcess you must have at least the following items in the build path for your Java project (or on your CLASSPATH):
the Jackcess JAR file itself, and
the JAR files for its two mandatory compile-time dependencies from Apache: commons-lang and commons-logging.
In the Eclipse IDE that will look something like this:
Hello i read that I have to use the java client library in java to get the revisions list in google drive using google api. I use netbeans. I search for this question and I try to add the bib but i haven't get success. To download the library i visited this link and downloaded the "latest". but after add the jar files I get the message error that the package doesnt exist. Please someone help me!
Yes! I try this but it show the same erros. I add the lib but netbeans (8) show the error in the three lines code: "package [name] doesn't exist".
The three lines are these:
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.model.Revision;
import com.google.api.services.drive.model.RevisionList;
obs: the full code, taken in the google developers site is:
package javaapplication8;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.model.Revision;
import com.google.api.services.drive.model.RevisionList;
import java.io.IOException;
import java.util.List;
public class MyClass {
private static List<Revision> retrieveRevisions(Drive service,
String fileId) {
fileId = "1XpNdeTFBr2KygyfPtlowBvkpcaJJzjgLckrGjp5oOhg0";
try {
RevisionList revisions = service.revisions().list(fileId).execute();
return revisions.getItems();
} catch (IOException e) {
System.out.println("An error occurred: " + e);
}
return null;
}
}
If it is the error like package is missing, please check whether you have created a folder named com in your project or not. Also, every dot (.) indicates the levels of packages that you use in your project. Please check that com folder followed by the other folder names after every dot are present or not. I think this might help you. I answered your question based on my understanding (i.e, package issue which will be resolved by creating folders in your project. folders means packages). I am sorry if I gave you the wrong answer.
i am a novice to java and netbeans both and complete newbie to java telephony.I am trying to import JTAPI (java telephony api) in netbeans project for past few days but i am unable to do so. I tried a lot of things and searched almost everywhere on internet but couldn't find a solution. I am desperate to find a solution so any help would really be appreciated.
coming to point.
i downloaded Jtapi from
http://download.oracle.com/otndocs/jcp/jtapi-1.4-fr3-spec-oth-JSpec/
and saved the jtapi-1_4-fr3-spec.zip file on desktop
then made a new netbeans java project. then i right clicked on libraries tab under the project->click add zip/folder-> entered the location of downloaded api.
then added a java file named "MyOutCallObserver.java" in the project
i opened the Jtapi specification and copied the code for detecting calls and pasted in the project. this code is provided in the following link too.
http://www.brekeke.com/products/jtapi/JTAPIspecdoc/javax/telephony/package-summary.html
import javax.telephony.*;
import javax.telephony.events.*;
/*
* The MyOutCallObserver class implements the CallObserver
* interface and receives all events associated with the Call.
*/
public class MyOutCallObserver1 implements CallObserver {
public void callChangedEvent(CallEv[] evlist) {
for (int i = 0; i < evlist.length; i++) {
if (evlist[i] instanceof ConnEv) {
String name = null;
try {
Connection connection = ((ConnEv)evlist[i]).getConnection();
Address addr = connection.getAddress();
name = addr.getName();
} catch (Exception excp) {
// Handle Exceptions
}
String msg = "Connection to Address: " + name + " is ";
if (evlist[i].getID() == ConnAlertingEv.ID) {
System.out.println(msg + "ALERTING");
}
else if (evlist[i].getID() == ConnInProgressEv.ID) {
System.out.println(msg + "INPROGRESS");
}
else if (evlist[i].getID() == ConnConnectedEv.ID) {
System.out.println(msg + "CONNECTED");
}
else if (evlist[i].getID() == ConnDisconnectedEv.ID) {
System.out.println(msg + "DISCONNECTED");
}
}
}
}
}
but an compile-time error was generated in the project stating the import statement wasn't working. then i tried shifting the zip file to
C:\Program Files\Java\jdk1.7.0_25
C:\Program Files\Java\jdk1.7.0_25\jre\lib\ext
also i created a new library from tools menu and then added it to project
but nothing seemed to work.
after nothing was working i extracted the zip file and copied it where netbeans project was saved. i thought the problem was solved as there was no compile time error but another blood-sucking issue showed up! now the netbeans won't be able to import the CallObserver interface and appeared in dashed line and i had no clue about how to proceed.!
i will be really grateful to anyone who could tell me what am i not doing right and how to get it right.
I use NetBeans 8.0.1 I got the same situation but this is not the problem.I compile the project an there is no errors
I did the same thing like you.I extracted the jtapi zip file and copi and paste javax folder in my Source Packages in my project.When i build the project a got the following error.
Screenshot of error
After that i opened the file that contains error ASRConstants.java and there is on row 204 in comment has some symbol like square in word vendors.After i deleted it the project compiles successfully.
After that i copy and paste your code and compile also successfully.